Re: [Rd] Date conversion with as.POSIXct and as.POSIXlt (PR#9196)

From: Prof Brian Ripley <ripley_at_stats.ox.ac.uk>
Date: Fri 01 Sep 2006 - 10:21:28 GMT

You misunderstand the role of timezones.

as.POSIXct(Sys.Date())

is in UTC, as documented.

as.POSIXlt(Sys.Date())

does not have a timezone (POSIXlt objects do not need one).

as.POSIXct(as.POSIXlt(Sys.Date()))

means

as.POSIXct(as.POSIXlt(Sys.Date()), tz="")

which is asking to interpret this in the local timezone.

I've expanded the documentation, but I see no sign you had studied it so that it unlikely to help you.

On Fri, 1 Sep 2006, erich.neuwirth@univie.ac.at wrote:

> Full_Name: Erich Neuwirth
> Version: 2.3.1
> OS: Windows XP, Linux
> Submission from: (NULL) (131.130.135.167)
>
>
> Converting Sys.Date() to a POSIX compliant time type in different ways
> produces inconsistent results:
> > Sys.date()
> [1] "2006-09-01"
> > as.POSIXct(Sys.Date())
> [1] "2006-09-01 02:00:00 CEST"
> > as.POSIXlt(Sys.Date())
> [1] "2006-09-01"
> > as.POSIXct(as.POSIXlt(Sys.Date()))
> [1] "2006-09-01 01:00:00 CEST"
>
> Applying as.POSIXct directly or first applying as.POSIXlt and then
> applying as.POSIXct produces different results.
>
> This happens on Linux with timezone "CEST"
> > Sys.time()
> [1] "2006-09-01 11:03:36 CEST"
> and on Windows with timezone "W. Europe Daylight Time"
> > Sys.time()
> [1] "2006-09-01 11:11:15 W. Europe Daylight Time"
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

-- 
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-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Fri Sep 01 20:27:44 2006

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 Wed 06 Sep 2006 - 11:39:09 GMT.

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