A set of extensions and operators for date arithmetic in Swift.
Easily can create instances of NSDateComponents initialized to various intervals.
1.year()
// Equivalent to:
// let components = NSDateComponents()
// components.year = 1
5.years()
15.minutes()
1.month()####Supported intervals:
second(s)
minute(s)
hour(s)
day(s)
week(s)
month(s)
year(s)Add or subtract date intervals from instances of NSDate.
let today = NSDate()
today + 1.year() // 1 year from now
today - 2 month() // 2 months ago
today + 5.minutes() // 5 minutes from now You can also install this library using CocoaPods. Just add this line to your Podfile:
pod 'DateIntervalOperators'Then import library module like so:
import DateIntervalOperatorsYou can also install this library manually by copying DateIntervalOperators.swift to your project.
If you have comments, complaints or ideas for improvements, feel free to open an issue or a pull request.
Tim Schmitz
DateIntervalOperators is available under the MIT license. See the LICENSE file for more info.