Re: NSCalendarDate, NSTimer - Daylight Saving Time (DST) problem is tricky...
Re: NSCalendarDate, NSTimer - Daylight Saving Time (DST) problem is tricky...
- Subject: Re: NSCalendarDate, NSTimer - Daylight Saving Time (DST) problem is tricky...
- From: Simon Liu <email@hidden>
- Date: Wed, 6 Apr 2005 14:49:46 +0100
Just to add, here is what happens when DST is coming in.
timeIntervalSinceReferenceDate --- time set by NSCalendarData dateByYear:...
133574400 --- 27 Mar 05, 01:00:00 Europe/Brussels
133577995 --- 27 Mar 05, 01:59:55 Europe/Brussels
133577996 --- 27 Mar 05, 02:59:56 Europe/Brussels *** 1 hr jump occurs here
133578000 --- 27 Mar 05, 03:00:00 Europe/Brussels
On Apr 6, 2005 1:11 PM, Simon Liu <email@hidden> wrote:
> 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
>
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden