I'm not surprised that strange things happen if you try to handle times in the duplicated hour without specifying which time you mean. If your current time zone setting is something like EST5EDT that includes both daylight-saving and standard times then 2008-11-02 01:16:00 occured twice, so some of the calls to difftime() are ambiguous. If your time-zone setting specifies daylight-saving time or not, then some of the calls to difftime() involve times that did not exist. If you create POSIXt objects that unambiguously specify the times then things should be more predictable.

        -thomas

On Fri, 7 Nov 2008, Dennis Fisher wrote:

Colleagues,

I submitted this several days ago and no one responded, so I am trying
again, trying a different subject line:

I just encountered some unexpected behavior of difftime in
relationship to the change from daylight savings to standard time.

My understanding is that DST and ST take effect at 2AM.  However, the
results below suggests that R (version 2.8.0 in OS X) implements the
change at 2:16AM:

Expected:
difftime("2008-11-02 02:01:00", "2008-11-02 00:59:00")
Time difference of 2.033333 hours
difftime("2008-11-02 01:16:00", "2008-11-02 01:15:00")
Time difference of 1 mins
difftime("2008-11-02 01:18:00", "2008-11-02 01:17:00")
Time difference of 1 mins

Not expected:
difftime("2008-11-02 01:17:00", "2008-11-02 01:16:00")
Time difference of 1.016667 hours

Can anyone explain this?

Dennis


Dennis Fisher MD
P < (The "P Less Than" Company)
Phone: 1-866-PLessThan (1-866-753-7784)
Fax: 1-415-564-2220
www.PLessThan.com


        [[alternative HTML version deleted]]

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.


Thomas Lumley                   Assoc. Professor, Biostatistics
[EMAIL PROTECTED]       University of Washington, Seattle

______________________________________________
R-help@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.

Reply via email to