Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

North Bronson

macrumors 6502
Original poster
I'm trying to write an application to deal with turning wall times back and forth to system times. I don't really understand how to get around this one issue with Daylight Savings Time.

In Los Angeles, at 2:00 AM on 11/7/10, the clocks fell back to 1:00 AM. There were "two different" 1:00 AMs.

Code:
NSDate *date = [NSDate dateWithTimeIntervalSinceReferenceDate: 310809600];

NSLog(@"%f", [date timeIntervalSinceReferenceDate]);    //  This is the "first" 1:00 AM

NSDateComponents *components = [[NSCalendar currentCalendar] components: (NSYearCalendarUnit | NSMonthCalendarUnit | NSDayCalendarUnit | NSHourCalendarUnit) fromDate: date];

date = [[NSCalendar currentCalendar] dateFromComponents: components];

NSLog(@"%f", [date timeIntervalSinceReferenceDate]);    //  This is the "second" 1:00 AM

I am giving the calendar the system time of the first 1:00 AM, but the components being returned seem to represent the second 1:00 AM. How do I reliably specify arbitrary wall times to the system without having this issue?
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.