[R] Entering times around the start of daylight savings time

Ian Kennedy ian.ke at sympatico.ca
Thu Apr 29 16:28:20 CEST 2004


I'm having problems entering dates and times around when daylight savings time 
starts. If I type (on R 1.8.1 on Gentoo Linux)

>  ISOdatetime(2004,4,4,0:4,0,0,"GMT")
[1] "2004-04-03 19:00:00 EST" "2004-04-03 20:00:00 EST"
[3] "2004-04-03 22:00:00 EST" "2004-04-03 22:00:00 EST"
[5] "2004-04-03 23:00:00 EST"

Giving the times between 2:00 and 3:00 GMT on 4 April which are all off by one 
hour. I tried setting TZ (to "Canada/Eastern") but didn't see any change.

For comparison I tried the same thing in R 1.8.1 for Windows and got a similar 
error, but the one hour that is wrong is one hour early, rather than one hour 
late:
> ISOdatetime(2004,4,4,0:4,0,0,"GMT")
[1] "2004-04-03 19:00:00 Eastern Standard Time"
[2] "2004-04-03 20:00:00 Eastern Standard Time"
[3] "2004-04-03 20:00:00 Eastern Standard Time"
[4] "2004-04-03 22:00:00 Eastern Standard Time"
[5] "2004-04-03 23:00:00 Eastern Standard Time"

If I try the same thing on R 1.9 for OS X, I get the correct result, that is 
one hour intervals.

So far I've been able to enter times correctly for this period by using chron, 
multiplying by the number of seconds in a day and forcing the resulting 
number to be a POSIXct, but this seems too involved and probably unreliable.

Thanks for any suggestions,

Ian Kennedy




More information about the R-help mailing list