Re: [R] Does strptime(...,tz="GMT") do anything?

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Mon 08 Jan 2007 - 23:43:35 GMT

Is EST a timezone on your system? You have not told us your system, but on most the timezone in the Eastern US is EST5EDT, not EST. Similarly with PST. (See ?as.POSIXct.)

Remember that strptime returns an object of class "POSIXlt" and that has a 'isdst' field. The timezone controls that, but none of your examples are in a timezone that is on DST, nor would they be in EST5EDT or PST8PDT.

Rather than add 0, I think you want to convert to POSIXct, specifying the timezone (a valid one).

as.POSIXct(strptime("20061201 1:02",format="%Y%m%d %H:%M", tz="PST8PDT"),

            tz="PST8PDT")
[1] "2006-12-01 01:02:00 PST" On Mon, 8 Jan 2007, David Forrest wrote:

> Hi All
>
> In trying to correlate some tide gauge data I need to deal with varying
> timezones. From the documentation on strptime, it seemed that the tz
> variable might have some effect on the conversion, but I'm not seeing an
> effect.
>
>> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="PST")+0
> [1] "2006-12-01 01:02:00 EST"
>> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="")+0
> [1] "2006-12-01 01:02:00 EST"
>> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="GMT")+0
> [1] "2006-12-01 01:02:00 EST"
>> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="UTC")+0
> [1] "2006-12-01 01:02:00 EST"
>> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="EST")+0
> [1] "2006-12-01 01:02:00 EST"
>
> What is the recommended way of handling this? Computing and adding
> offsets manually?
>
>> strptime("20061201 1:02 PST",format="%Y%m%d %H:%M",tz="UTC")+3600*3
> [1] "2006-12-01 04:02:00 EST"
>
> Or am I doing something wrong with the strptime(..., tz="EST") function?
>
> Thanks for your time,
> Dave
>

-- 
Brian D. Ripley,                  ripley@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

______________________________________________
R-help@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.
Received on Tue Jan 09 17:04:36 2007

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.1.8, at Tue 09 Jan 2007 - 06:30:30 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-help. Please read the posting guide before posting to the list.