From ggrothendieck at gmail.com  Fri Sep  1 12:25:36 2006
From: ggrothendieck at gmail.com (Gabor Grothendieck)
Date: Fri, 1 Sep 2006 06:25:36 -0400
Subject: [Rd] Date conversion with as.POSIXct and as.POSIXlt (PR#9196)
In-Reply-To: <20060901092716.784165866B@slim.kubism.ku.dk>
References: <20060901092716.784165866B@slim.kubism.ku.dk>
Message-ID: <971536df0609010325v45e18cd9ub7194b98f4965d52@mail.gmail.com>

Note that there is some discussion in the help desk article
in R News 4/1 and a table of tested conversions at
the end of that article.    If x is of class "Date" then for
converting from Date to POSIXct the table suggests
as.POSIXct(format(x)) or as.POSIXct(format(x), tz = "GMT")
according to whether you want the current time zone or GMT.

On 9/1/06, erich.neuwirth at univie.ac.at <erich.neuwirth at 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 at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>




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