I have this method in Objective-C to return the time stamp of the location sent to the server.
-(NSDate *) toLocalTime
{
NSTimeZone *tz = [NSTimeZone defaultTimeZone];
NSInteger seconds = [tz secondsFromGMTForDate: [NSDate date]];
return [NSDate dateWithTimeInterval: seconds sinceDate: [NSDate date]];
}
This works perfectly in Obj-C I have converted it to swift 2.0
func toLocalTime() -> NSDate {
var tz : NSTimeZone = NSTimeZone.defaultTimeZone()
var seconds: Int = tz.secondsFromGMTForDate(NSDate())
return (NSDate(timeInterval: seconds, sinceDate: NSDate()))
}
but when I convert this to swift 2.0 , error(mentioned as the title above) is shown for this line as the variable seconds is of type Int and the variable that should be passed to dateWithTimeInterval should be NSTimeInterval.
Error:Cannot convert the type 'int' to expected type NSTimeInterval
Error line: return (NSDate(timeInterval: seconds, sinceDate: NSDate()))
please help !