Skip to content
Prev 8932 / 63424 Next

POSIX problem in New Zealand (PR#2570)

On Fri, 21 Feb 2003 ripley@stats.ox.ac.uk wrote:

            
Currently I'm in New Zealand working on a Windows XP machine that has
never left the country. I have not encountered problems with as.POSIXct
when working in other time zones.
I'm dealing with two kinds of problems: (1) what I see as a bug in
as.POSIXct, and (2) my own confusion with time zones. One problem at a
time:


(1) as.POSIXct

I would like the following to return similar times, except for the year,
but they don't:
 > x <- as.POSIXct("1969-12-24")
 > y <- as.POSIXct("1970-12-24")
 > x
 [1] "1969-12-23 23:00:00 New Zealand Standard Time"
 > y
 [1] "1970-12-24 New Zealand Standard Time"
 > z <- seq(x, by="year", length=2)[2]
 > difftime(y, z)
 Time difference of 1 hours
queries Windows XP for the period 1970-2037 and uses its own C code
outside this range. To me it looks like the bug might be in the C code. I
think the problem goes deeper than print.POSIXct, because coercions are
independent of the print method as far as I understand:

 > x <- as.POSIXlt("1969-12-24")
 > y <- as.POSIXlt(as.POSIXct(x))
 > x
 [1] "1969-12-24"
 > y
 [1] "1969-12-23 23:00:00 New Zealand Standard Time"
 > x==y
 [1] FALSE


(2) Time zone confusion

This is a question of taste and implementation, but I would like POSIXct
objects in data frames and plots to display the times I entered
originally, regardless of where in the world I'm working at the moment.


(3) My solution

I've defined the environment variable tz=GMT in my R shortcut and I'll try
to remember doing so on other machines I work on. This way I avoid both
the as.POSIXct/New Zealand bug and the time zone confusion. I still think
the Kiwis would appreciate the bug being fixed :)