I am trying to combine the time value (hours, minutes, seconds) of one NSDate with the date value (day, month, year) of a second NSDate with this m
Here it is in Swift 2
func combineDateAndTime(date: NSDate, time: NSDate) -> NSDate {
let calendar = NSCalendar.currentCalendar()
let dateComponents = calendar.components([.Year, .Month, .Day], fromDate: date)
let timeComponents = calendar.components([.Hour, .Minute, .Second], fromDate: time)
let components = NSDateComponents()
components.year = dateComponents.year
components.month = dateComponents.month
components.day = dateComponents.day
components.hour = timeComponents.hour
components.minute = timeComponents.minute
components.second = timeComponents.second
return calendar.dateFromComponents(components)!
}