Timepiece is a library from Naoto Kaneko that makes working with NSDate objects a bit more intuitive.
let now = NSDate()
let theForceAwakens = now + 218.days + 2.hours + 34.minutes
It also aids in quickly parsing dates from or rendering dates to a String
:
let judgementDay = "1997-08-29".dateFromFormat("yyyy-MM-dd")
1.day.later.stringFromFormat("EEEE") // "Thursday"
Comparisons are simplified as well:
if (birthday > 40.years.ago) {
midLifeCrisis()
}
How to Use Timepiece
In our Podfile
:
platform :ios, '8.0'
pod 'Timepiece'
In any Swift file:
import Timepiece
More info about Timepiece can be found at git.io/timepiece