Skip to content

Instantly share code, notes, and snippets.

@davbeck
Created October 8, 2016 04:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save davbeck/0a9be64c2d77de3122da538283669d90 to your computer and use it in GitHub Desktop.
Save davbeck/0a9be64c2d77de3122da538283669d90 to your computer and use it in GitHub Desktop.
func testFormatterKit() {
let timeFormatter = TTTTimeIntervalFormatter()
timeFormatter.presentTimeIntervalMargin = 60
timeFormatter.usesIdiomaticDeicticExpressions = true
self.measure {
let timeFormatter = TTTTimeIntervalFormatter()
timeFormatter.presentTimeIntervalMargin = 60
timeFormatter.usesIdiomaticDeicticExpressions = true
var timeInterval: TimeInterval = 1
for i in 1..<iterations {
timeInterval *= TimeInterval(i)
timeFormatter.string(forTimeInterval: -timeInterval)
}
}
XCTAssertEqual(timeFormatter.string(forTimeInterval: -60), "1 minute ago")
}
func testMoments() {
self.measure {
var timeInterval: TimeInterval = 1
for i in 1..<iterations {
timeInterval *= TimeInterval(i)
_ = Moment(Date(timeIntervalSinceNow: -timeInterval))?.fromNow()
}
}
XCTAssertEqual(Moment(Date(timeIntervalSinceNow: -60))?.fromNow(), "a minute ago")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment