[R] daylight saving time problems
wouter buytaert
wouter.buytaert at yucom.be
Sun Jun 8 13:41:40 CEST 2003
Hello,
sorry for my mail yesterday about the POSIXct problems. I was a bit
tired and now I found out the real problem. When importing time data
over a daylight saving time shift, R shifts two times. I don't now
whether it is a bug or a (wrongly used) feature
If you execute the following code:
--------------
test<-c("31/03/2002 0:00", "31/03/2002 0:15", "31/03/2002 0:30",
"31/03/2002 0:45", "31/03/2002 1:00", "31/03/2002 1:15", "31/03/2002
1:30", "31/03/2002 1:45", "31/03/2002 2:00", "31/03/2002 2:15",
"31/03/2002 2:30", "31/03/2002 2:45", "31/03/2002 3:00", "31/03/2002
3:15", "31/03/2002 3:30", "31/03/2002 3:45", "31/03/2002 4:00",
"31/03/2002 4:15", "31/03/2002 4:30", "31/03/2002 4:45", "31/03/2002
5:00", "31/03/2002 5:15", "31/03/2002 5:30", "31/03/2002 5:45",
"31/03/2002 6:00");
timetest<-strptime(as.character(test), format = "%d/%m/%Y %H:%M");
timetest2<-as.POSIXct(timetest);
--------------
then R 1.7.0 gives on my Mandrake 9.1:
> test
[1] "31/03/2002 0:00" "31/03/2002 0:15" "31/03/2002 0:30" "31/03/2002
0:45"
[5] "31/03/2002 1:00" "31/03/2002 1:15" "31/03/2002 1:30" "31/03/2002
1:45"
[9] "31/03/2002 2:00" "31/03/2002 2:15" "31/03/2002 2:30" "31/03/2002
2:45"
[13] "31/03/2002 3:00" "31/03/2002 3:15" "31/03/2002 3:30" "31/03/2002
3:45"
[17] "31/03/2002 4:00" "31/03/2002 4:15" "31/03/2002 4:30" "31/03/2002
4:45"
[21] "31/03/2002 5:00" "31/03/2002 5:15" "31/03/2002 5:30" "31/03/2002
5:45"
[25] "31/03/2002 6:00"
>
> timetest
[1] "2002-03-31 00:00:00" "2002-03-31 00:15:00" "2002-03-31 00:30:00"
[4] "2002-03-31 00:45:00" "2002-03-31 01:00:00" "2002-03-31 01:15:00"
[7] "2002-03-31 01:30:00" "2002-03-31 01:45:00" "2002-03-31 03:00:00"
[10] "2002-03-31 03:15:00" "2002-03-31 03:30:00" "2002-03-31 03:45:00"
[13] "2002-03-31 03:00:00" "2002-03-31 03:15:00" "2002-03-31 03:30:00"
[16] "2002-03-31 03:45:00" "2002-03-31 04:00:00" "2002-03-31 04:15:00"
[19] "2002-03-31 04:30:00" "2002-03-31 04:45:00" "2002-03-31 05:00:00"
[22] "2002-03-31 05:15:00" "2002-03-31 05:30:00" "2002-03-31 05:45:00"
[25] "2002-03-31 06:00:00"
>
> timetest2
[1] "2002-03-31 00:00:00 CET" "2002-03-31 00:15:00 CET"
[3] "2002-03-31 00:30:00 CET" "2002-03-31 00:45:00 CET"
[5] "2002-03-31 01:00:00 CET" "2002-03-31 01:15:00 CET"
[7] "2002-03-31 01:30:00 CET" "2002-03-31 01:45:00 CET"
[9] "2002-03-31 03:00:00 CEST" "2002-03-31 03:15:00 CEST"
[11] "2002-03-31 03:30:00 CEST" "2002-03-31 03:45:00 CEST"
[13] "2002-03-31 03:00:00 CEST" "2002-03-31 03:15:00 CEST"
[15] "2002-03-31 03:30:00 CEST" "2002-03-31 03:45:00 CEST"
[17] "2002-03-31 04:00:00 CEST" "2002-03-31 04:15:00 CEST"
[19] "2002-03-31 04:30:00 CEST" "2002-03-31 04:45:00 CEST"
[21] "2002-03-31 05:00:00 CEST" "2002-03-31 05:15:00 CEST"
[23] "2002-03-31 05:30:00 CEST" "2002-03-31 05:45:00 CEST"
[25] "2002-03-31 06:00:00 CEST"
There is a clear time shift timetest[8] and timetest[9] and another one
between timetest[12] and timetest[13]. I.e. timetest[9:12] are wrongly
converted.
In october (reverse timeshift in daylight time) there is no shift at
all.
It seems that it was a feature before that has been badly patched.
I'm using R 1.7.0 on Mandrake Linux in Belgium (CEST?)
It does not occur on my MacOSX box (both Darwin and Carbon version); I
don't now about the windows version.
Thanks,
Wouter Buytaert
More information about the R-help
mailing list