[Rd] POSIX problem in New Zealand (PR#2570)

Arni Magnusson arnima@u.washington.edu
Sat Feb 22 06:13:11 2003


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

> What exactly is the problem?  Those appear to be the same time, in
> different time zones.  Is the problem that you are in the N Hemisphere
> (your email address is) trying to use S Hemisphere times on an OS that
> does not support pre-1970 times?

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.


> You seem to be confusing the time and how it is printed.  What do you
> want to do with these times?

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

>From reading 'library/base/html/DateTimeClasses.html' I understand that R
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 :)




> On Fri, 21 Feb 2003 arnima@u.washington.edu wrote:
>
> > Full_Name: Arni Magnusson
> > Version: 1.6.2
> > OS: Windows XP
> > Submission from: (NULL) (210.48.49.68)