ggrothendieck@volcanomail.com
2003-Aug-04 05:06 UTC
[Rd] Windows 2000 Bug in GMT +/- n Timezones (PR#3644)
Tracking down this bug was joint work with Jermoe Asselin (jerome at hivnet.ubc.ca) and Patrick Connolly (p.connolly at hortresearch.co.nz). We collectively were able to determine that this is a problem in Windows 2000 but not in Linux. Timezones of the form GMT-5, GMT+3, etc. do not work properly in Windows 2000 for nearby dates in daylight savings time although they do work for nearby dates not in daylight savings time and in far away dates. (Apparently nearby dates are processed by the OS and far away ones by R.) This appears to be a Windows specific problem as these timezones do give correct results in Linux. Run the code below on Windows 2000 and it will display a table like the one later on. The rows are timezones and the columns are dates. The entries in the table are the hours between GMT and the date/timezone for that cell. For example, for the 1995-06-29 column, the row labelled GMT+1 gives the the time difference between 1995-06-29 GMT and 1995-06-29 GMT+1. It shows that the two times are equal but they should be one hour different. In fact, examining this same column we see that all the cells that correspond to GMT+n and GMT-n for each n are wrong by one hour. # start of code my.outer <- function(x,y,f) { # same as outer but can accept functions with scalar args # (whereas outer only takes functions that can take vector args) ff <- function(z) f(z[[1]],z[[2]]) outer( x, y, function(x,y)apply(data.frame(x,y),1,ff) ) } my.tz <- c("XYZ", "EST", "EDT", "PST", "PDT", "NZT", "NZST", "NZDT", "ET", "PT", "", "GMT-5", "GMT-4", "GMT-3", "GMT-2", "GMT-1", "GMT", "GMT+1", "GMT+2", "GMT+3", "GMT+4", "GMT+5") names(my.tz) <- my.tz "my.dates" <- c("1895-06-29", "1995-01-29", "1995-06-29", "2095-06-29") names(my.dates) <- my.dates f <- function(d,z) as.POSIXct(d,tz=z) - as.POSIXct(d,tz="GMT") tab <- t( my.outer( my.dates, my.tz, f ) ) paste(R.version); Sys.timezone(); tab # end of code to copy On a Eastern Daylight Time Windows 2000 machine it produces this: [1] "i386-pc-mingw32" "i386" "mingw32" "i386, mingw32" [5] "" "1" "7.1" "2003" [9] "06" "16" "R" [1] "Eastern Daylight Time" 1895-06-29 1995-01-29 1995-06-29 2095-06-29 XYZ 0 0 -1 0 EST 0 0 -1 0 EDT 0 0 -1 0 PST 0 0 -1 0 PDT 0 0 -1 0 NZT 0 0 -1 0 NZST -1 0 -1 -1 NZDT -1 0 -1 -1 ET -1 0 -1 -1 PT -1 0 -1 -1 4 5 4 4 GMT-5 -5 -5 -6 -5 GMT-4 -4 -4 -5 -4 GMT-3 -3 -3 -4 -3 GMT-2 -2 -2 -3 -2 GMT-1 -1 -1 -2 -1 GMT 0 0 0 0 GMT+1 1 1 0 1 GMT+2 2 2 1 2 GMT+3 3 3 2 3 GMT+4 4 4 3 4 GMT+5 5 5 4 5 Also most of the timezones don't work and either give the same result as XYZ (which is a clearly invalid timezone) or else deviate from the XYZ row by one hour. Although not shown "Eastern Daylight Time", "Eastern Standard Time", "Eastern Time" and "Eastern XYZ Time" all give the same result as for row ET above.
Possibly Parallel Threads
- as.POSIXct Bug when used with POSIXlt arg and tz= arg (PR#3646)
- Incorrect DST time changes in DateTimeClasses
- How to get time differences in consistent units?
- Status of Timezone support / Handeling DTSTART; TZID="(GMT-05.00) Eastern Time (US & Canada)":20080107T123000
- time zones, daylight saving etc.