[R] bug in as.POSIXct ?

Jason Turner jasont at indigoindustrial.co.nz
Thu Dec 4 20:14:27 CET 2003


apjaworski at mmm.com wrote:

> I think that there is a bug in the as.POSIXct function on Windows.
> 
>  Here is what I get on Win2000, Pentium III machine in R 1.8.1.
> 
> 
>>dd1 <- ISOdatetime(2003, 10, 26, 0, 59, 59)
>>dd2 <- ISOdatetime(2003, 10, 26, 1, 0, 0)
>>dd2 - dd1
> 
> Time difference of 1.000278 hours
> 
> Now, the 26th of October was the day that change to the standard time
> occurred, so I suspect that this has something to do with that.  In fact
> 
> 
>>dd1
> 
> [1] "2003-10-26 00:59:59 Central Daylight Time"
> 
>>dd2
> 
> [1] "2003-10-26 01:00:00 Central Standard Time"
> 
> so it looks like the switch from CDT to CST happens at 1:00 (instead of
> 2:00 ?).
> 

Or, it did happen at 2:00 CDT, when the time fell back one hour to 1:00 
CST.  1:00 am occured twice on that day, once as CDT and once as CST.  R 
picked the last one.  A bit pathological at first glance, but 
date-handling often is.

As for the dd2 - dd1 value, the "correct" value depends which 1:00 am 
was chosen.  On Windows, this should be 1 hour, 1 second, no?  I'm 
thinking 1:00 am CST == 2:00 am CDT, so in CDT entirely, your expression 
is basicly 02:00:00 CDT - 00:59:59 CDT.

This makes me suspect that Linux picked the former 1:00 am, from your 
report.  Since R gets its date intricacies from the OS, there really 
isn't much that can be done about this, until someone builds a full 
POSIX time implementation that takes all the world's locales and time 
zones into account, and welds it into R.  Volunteers?

It's things like this that make me convert everything to UCT (GMT, or 
Zulu, if you prefer).  Not R's fault; stupid calendar tricks are to 
blame here.

Cheers

Jason
-- 
Indigo Industrial Controls Ltd.
http://www.indigoindustrial.co.nz
64-21-343-545
jasont at indigoindustrial.co.nz




More information about the R-help mailing list