Re: [R] Unexpected behavior of clocktime related to daylight savings time
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.03 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.
Re: [R] Unexpected behavior of clocktime related to daylight savings time
Professor Ripley, My apologies for not clarifying the timezone - I am in California (PDT - PST). I did review various help pages and I am still unclear on the explanation. I replicated your code: as.POSIXct(2008-11-02 01:17:00) [1] 2008-11-02 01:17:00 PST as.POSIXct(2008-11-02 01:17:00) + 3600 [1] 2008-11-02 02:17:00 PST Your second command yielded 1:17; mine yielded 2:17. On my OS X machine (R 2.8.0): Sys.timezone() [1] i.e., Sys.timezone returns an empty string. So, the question remains: is this an OS issue or an R issue (i.e., my difftime commands below appear to show that DST takes effect as 1:16, not 1:100)? 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 On Nov 7, 2008, at 8:05 AM, Prof Brian Ripley wrote: 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: Well, you posted something that indicated you had not studied the relevant help pages, without the information requested in the R posting guide, and with an HTML posting. 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: The transition time depends on the country (and in some cases, the year). In the EU it is at 2am (and always has been, not that the EU is very old). Expected: difftime(2008-11-02 02:01:00, 2008-11-02 00:59:00) Time difference of 2.03 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? Yes, and you should have been able to do so from the information in the help pages. As ?strptime says Remember that in most timezones some times do not occur and some occur twice because of transitions to/from summer time. What happens in those cases is OS-specific. See also the note on ?Sys.timezone. No OS I tried did this, not even Mac OS X set to EST5EDT. But in EST5EDT 2008-11-02 01:17:00 occurred twice: as.POSIXct(2008-11-02 01:17:00) [1] 2008-11-02 01:17:00 EDT as.POSIXct(2008-11-02 01:17:00) + 3600 [1] 2008-11-02 01:17:00 EST so 1.016667 hours would be one of two correct answers in that timezone. However, you didn't tell us what timezone you are in and hence we cannot know when DST transitions occur in that timezone. Dennis -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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.
[R] Unexpected behavior of clocktime related to daylight savings time
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.03 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.
Re: [R] Unexpected behavior of clocktime related to daylight savings time
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: Well, you posted something that indicated you had not studied the relevant help pages, without the information requested in the R posting guide, and with an HTML posting. 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: The transition time depends on the country (and in some cases, the year). In the EU it is at 2am (and always has been, not that the EU is very old). Expected: difftime(2008-11-02 02:01:00, 2008-11-02 00:59:00) Time difference of 2.03 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? Yes, and you should have been able to do so from the information in the help pages. As ?strptime says Remember that in most timezones some times do not occur and some occur twice because of transitions to/from summer time. What happens in those cases is OS-specific. See also the note on ?Sys.timezone. No OS I tried did this, not even Mac OS X set to EST5EDT. But in EST5EDT 2008-11-02 01:17:00 occurred twice: as.POSIXct(2008-11-02 01:17:00) [1] 2008-11-02 01:17:00 EDT as.POSIXct(2008-11-02 01:17:00) + 3600 [1] 2008-11-02 01:17:00 EST so 1.016667 hours would be one of two correct answers in that timezone. However, you didn't tell us what timezone you are in and hence we cannot know when DST transitions occur in that timezone. 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 -- Brian D. Ripley, [EMAIL PROTECTED] Professor of Applied Statistics, http://www.stats.ox.ac.uk/~ripley/ University of Oxford, Tel: +44 1865 272861 (self) 1 South Parks Road, +44 1865 272866 (PA) Oxford OX1 3TG, UKFax: +44 1865 272595 __ 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.