Skip to content

Instantly share code, notes, and snippets.

@michaeleisel
Created January 7, 2015 16:38
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 michaeleisel/3f3bf19bda1f358dd8e2 to your computer and use it in GitHub Desktop.
Save michaeleisel/3f3bf19bda1f358dd8e2 to your computer and use it in GitHub Desktop.
public extension NSDate {
var calendarComponents: NSDateComponents {
get {
//let componentFlags: NSCalendarUnit = NSCalendarUnit(CalendarUnitEra)
let componentFlags = NSCalendarUnit(UInt.max)
return NSDate.currentCalendar().components(componentFlags, fromDate:self)
}
}
var hour: Int {
get {
return calendarComponents.hour
}
mutating set (newHours) {
self += Double(newHours)
}
}
}
func += (inout date: NSDate, timeInterval: Double) {
date = date + timeInterval
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment