Swift Date Management Library

Daniele Margutti on his Swift Date Management project:

  • Math operations with dates (ie. myDate+2.week+1.hour)
  • Easy compare using <,>,==,<=,>= operators
  • Easy individual date component set/get
  • Easy creation with common formats or custom formats
  • Powerful .toString methods with support for relative dates (ie. “2hours”…)
  • Many shortcuts to get intervals and common dates (yesterday,tomorrow…)

Code like this, made possible by Daniele’s library, can be really handy:

[code lang=text]
let date = NSDate()
let tomorrow = date+1.day
let 2_months_ago = date-2.months
let next_year_today = date+1.year