Created
January 7, 2016 19:57
-
-
Save Lbatson/99a68b525482bc81ba0d to your computer and use it in GitHub Desktop.
This file contains 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
func setTimeForDate (date: NSDate, hour: Int, minute: Int, second: Int) -> NSDate { | |
let unitFlags = [.Year, .Month, .Day, .Hour, .Minute, .Second] as NSCalendarUnit | |
// calendar here is NSCalendar.currentCalendar() | |
let dateComponents = calendar.components(unitFlags, fromDate: date) | |
dateComponents.hour = hour | |
dateComponents.minute = minute | |
dateComponents.second = second | |
let newDate = calendar.dateFromComponents(dateComponents) | |
print(newDate) | |
return newDate! | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment