ios - Why is date.dateByAddingTimeInterval(seconds) off by 1 hour? -
Why do back one hour .dateByAddingTimeInterval () is the difference? Daylight savings are currently not implemented, so this should not have any effect on this. ? I'm & Gt - (string = "What did I do wrong
static imports Foundation struct Gigasecond {newDate function yyyy-MM-dd": string, format input) ; NSDate {var dateFormatter = NSDateFormatter () dateFormatter.dateFormat = Format Return Date FormatMade Data Frame String (Input) ?? NSDate.distantFuture (as NSDate) from stable funk (dateInString: string) - & gt; NSDate {var dateIn = newDate (dateInString) return dateIn.dateByAddingTimeInterval (1_000_000_000)}} to newDate23 = Gigasecond.newDate ( "2043-01-01T01: 46: 40", format: "yyyy-MM-dd'T'HH: mm :. SS ") println (Gigasecond.from (" 2011/04/25 ") timeIntervalSinceDate (newDate23)) //-3600.0 or 1 hour (60 * 60) Text after "
What will happen if you are clearly set to a time-scale formatter
struct Gigasecond {Fixed function NewDate (Input: string, format: string = "yyyy-MM-dd") - & gt; NSDate {var dateFormatter = NSDateFormatter () dateFormatter.dateFormat = Format // Clearly formatter dateFormatter.timeZone = NSTimeZone (forSecondsFromGMT: 0) Returns the time zone set dateFormatter.dateFromString (input) ?? NSDate.distantFuture (as NSDate) from stable funk (dateInString: string) - & gt; NSDate {var dateIn = newDate (dateInString) Return Date In.dateByAddingTimeInterval (1_000_000_000)}} Nidet 23 = Gigasecond.newDate ( "2011-4-25T01: 46: 40", format: "yyyy-MM-dd'T'HH : mm: ss ") Println (Gigasekandkfrom (" 25/04/2011 ") Timentrvlsinkedate (Newdte23))
Comments
Post a Comment