This is a working function who rounds off the minutes to nearest five. What I need is it to return the time in a specific timezone, so whetheryou're in timezoon +1, +5 or whatever, it must return timezone +1. Anyone knows how i can solve this?
func SkipToEvenFiveMinutes(date:NSDate) -> NSDate!
{
let componentMask : NSCalendarUnit = ([NSCalendarUnit.Year , NSCalendarUnit.Month , NSCalendarUnit.Day , NSCalendarUnit.Hour ,NSCalendarUnit.Minute, NSCalendarUnit.Second+NSTimeZone setDefaultTimeZone:UTC+1])
let components = NSCalendar.currentCalendar().components(componentMask, fromDate: date)
let current = components.minute * 60
let currentSeconds = current + components.second
let diff = currentSeconds % (60 * 5);
let difference = Double(diff)
if (difference > 60.0 * 2.5) {
components.second += 60 * 5 - diff
} else {
components.second -= diff
}
return NSCalendar.currentCalendar().dateFromComponents(components)!
}