[R] time zones in POSIXt

Prof Brian Ripley ripley at stats.ox.ac.uk
Sat Apr 24 08:47:55 CEST 2004


On Fri, 23 Apr 2004, Vadim Ogranovich wrote:

> Thank you for the lead, Dirk! Indeed this works on my machine too:
> 
> > as.POSIXct("2000-05-10 10:15:00",  tz="PST8PDT") -
> as.POSIXct("2000-05-10 10:15:00",  tz="GMT")
> Time difference of 7 hours
> 
> 
> However when I replace POSIXct by POSIXlt it breaks (this looks like a
> bug to me):
> 
> > as.POSIXlt("2000-05-10 10:15:00",  tz="PST8PDT") -
> as.POSIXlt("2000-05-10 10:15:00",  tz="GMT")
> Time difference of 0 secs

No, it's not a bug.  POSIXlt times are just numeric representations of
broken-down times, and the tzone attribute (which is normally not present)
is just a reminder to you.  (It has not been checked, so this is avoid
nasty surprises if it is wrong.)  Maybe it was a bad idea to allow - for
POSIXlt times, but then we do expect users to read the documentation
(including the code if they are puzzled).

> Now a couple of new questions:
> * how could I learn about appropriate names for time zones? For example
> I was using "PST" whereas it seems I had to use either "PST8" or
> "PST8PDT". Why "PST" was not good? Is it documented anywhere?

Specific to your OS, so I expect it documents it somewhere.

> * there seems to be no difference betweeen GMT and BST on my machine
> though PST8 and PST8PDT are treated properly:
> 
> # PST8 is not identical to PST8PDT
> > ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz="PST8") - ISOdatetime(2003,
> seq(12), 1, 10, 0, 0, tz="PST8PDT")
> Time differences of    0,    0,    0,    0, 3600, 3600, 3600, 3600,
> 3600, 3600,    0,    0 secs
> 
> # GMT0 is identical to BST
> > ISOdatetime(2003, seq(12), 1, 10, 0, 0, tz="GMT0") - ISOdatetime(2003,
> seq(12), 1, 10, 0, 0, tz="BST")
> Time differences of 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 secs
> 
> Why is such dichotomy?

Ask your OS designer - timezones are handled by your OS.  I would not 
consider "BST" to be a timezone as it is only defined for half the year.
Windiows thinks I am on `GMT Daylight Time' although that usage is 
otherwise unknown in this country.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list