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 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