Skip to content

Commit

Permalink
Merge pull request #320 from wordpress-mobile/remove-formatter-kit
Browse files Browse the repository at this point in the history
Remove FormatterKit as a dependency
  • Loading branch information
crazytonyli authored Nov 9, 2022
2 parents 7099c04 + 4a00d04 commit b8058f6
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 27 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,4 @@ _None._
### Internal Changes

- Add this changelog entry about changelog itself [#317]
- Remove FormatterKit [#320]
2 changes: 1 addition & 1 deletion Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -52,4 +52,4 @@ SPEC CHECKSUMS:

PODFILE CHECKSUM: ace859cfebf0a7a9ce551e216483b641cd360251

COCOAPODS: 1.10.2
COCOAPODS: 1.11.3
1 change: 0 additions & 1 deletion WordPressShared.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,4 @@ Pod::Spec.new do |s|
s.header_dir = 'WordPressShared'

s.dependency 'CocoaLumberjack', '~> 3.4'
s.dependency 'FormatterKit/TimeIntervalFormatter', ' ~> 1.8'
end
26 changes: 1 addition & 25 deletions WordPressShared/Core/Utility/NSDate+Helpers.swift
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import Foundation
import FormatterKit

extension Date {
/// Private Date Formatters
Expand Down Expand Up @@ -67,17 +66,6 @@ extension Date {
formatter.timeStyle = .short
return formatter
}()

@available(*, deprecated, message: "Not used as far as I can tell -@jkmassel Mar 2021")
static let pageSectionFormatter: TTTTimeIntervalFormatter = {
let formatter = TTTTimeIntervalFormatter()

formatter.leastSignificantUnit = .day
formatter.usesIdiomaticDeicticExpressions = true
formatter.presentDeicticExpression = NSLocalizedString("today", comment: "Today")

return formatter
}()
}

/// Returns a NSDate Instance, given it's ISO8601 String Representation
Expand Down Expand Up @@ -120,19 +108,7 @@ extension Date {

@available(*, deprecated, renamed: "toMediumString", message: "Removed to help drop the deprecated `FormatterKit` dependency – @jkmassel, Mar 2021")
public func mediumString(timeZone: TimeZone? = nil) -> String {
let relativeFormatter = TTTTimeIntervalFormatter()
let absoluteFormatter = DateFormatters.mediumDate

if let timeZone = timeZone {
absoluteFormatter.timeZone = timeZone
}

let components = Calendar.current.dateComponents([.day], from: self, to: Date())
if let days = components.day, abs(days) < 7 {
return relativeFormatter.string(forTimeInterval: timeIntervalSinceNow)
} else {
return absoluteFormatter.string(from: self)
}
toMediumString(inTimeZone: timeZone)
}

/// Formats the current date as relative date if it's within a week of
Expand Down

0 comments on commit b8058f6

Please sign in to comment.