Created
January 7, 2015 16:38
-
-
Save michaeleisel/3f3bf19bda1f358dd8e2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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