Skip navigation.
 
mlNSCalendarDate, NSTimer - Daylight Saving Time (DST) problem is tricky...
FROM : Simon Liu
DATE : Wed Apr 06 14:11:27 2005

Hi,

I'm trying to implement a timer based scheduler.  When DST ends, how
does that affect NSTimers?  Is there any documentation and specs on
how NSCalendarDate and NSTimers behave when moving from DST to
non-DST?

For example, 30 Oct 05, in Europe/Brussels timezone, at 02:00, clocks
go back as DST ends.  So the time is actually like this:
01:00:00 --> 01:59:59 --> 01:00:00 --> 01:59:59 --> 02:00:00
There are "physically" two hours between 01:00 and 02:00.  More info
is here: http://www.timeanddate.com/time/aboutdst.html

Say you have a timer set to fire at 01:30:00, since it happens twice,
when should it fire?  From some investigation, it seems that with
NSCalendarDate, 01:30:00 only occurs once, so what happened to the
second occurence?

Using NSCalendarDate, I notice that things start happening around
01:59:52.  If you set times by using [NSCalendarDate
dateWithYear:month:day:hour:minute:second:timezone:] class method, and
then ask for the -timeIntervalSinceReferenceDate, here's what you get.

timeIntervalSinceReferenceDate --- time set
152323192 --- 30 Oct 05, 01:59:52 Europe/Brussels
152326793 --- 30 Oct 05, 01:59:53 Europe/Brussels *** Notice the
timeInterval jump
152326800 --- 30 Oct 05, 02:00:00 Europe/Brussels

So what happens if we set the date by time interval using
-initWithTimeIntervalSinceReferenceDate:
-setTimeZone:

152323193 --- 30 Oct 05, 01:59:53 Europe/Brussels
152323201 --- 30 Oct 05, 02:00:01 Europe/Brussels *** Why not 01:00:01 ?
152326800 --- 30 Oct 05, 02:00:00 Europe/Brussels

With a time interval of 152323201, the time is actually further in
future than a time interval of 152326800 - how strange.  Why does the
time being represented not go back the hour?

Any Apple engineers or other folks out there who can shed some light?
I'm trying to implement a scheduler and any advice or general
guidelines on how to deal with this DST issue of a repeating hour
would be appreciated.

BTW: I haven't discussed the clocks going forward as that seeks a
little clearer.  If the clocks go forward at 2am by 1 hour, then the
time jumps from 01:59:59 --> 03:00:00 and any times supposedly from
02:00:00 to 02:59:59 are actually invalid (or should be considered as
such).

Regards,
Simon