Re: [Rd] Date conversion with as.POSIXct and as.POSIXlt

From: Erich Neuwirth <erich.neuwirth_at_univie.ac.at>
Date: Thu 07 Sep 2006 - 08:34:08 GMT


After the discussions which really helped me understanding the issues involved let me summarize some possibly surprising behavior of as.POSIXlt and as.POSIXct and the print method of class POSIXlt (the print method problem seems to be a Windows only problem) in R 2.3.1

> as.POSIXct(firstjan)

[1] "2006-01-01 01:00:00 CET"
> as.POSIXct(firstjan,tz="HST10")

[1] "2006-01-01 01:00:00 CET"
> as.POSIXlt(firstjan)

[1] "2006-01-01"
> as.POSIXlt(firstjan,tz="HST10")

[1] "2006-01-01"
> as.POSIXct(as.character(firstjan))

[1] "2006-01-01 CET"
> as.POSIXct(as.character(firstjan),tz="HST10")
[1] "2006-01-01 HST"
> as.POSIXlt(as.character(firstjan))

[1] "2006-01-01"
> as.POSIXlt(as.character(firstjan),tz="HST10")
[1] "2006-01-01 HST10"   Furthermore, for string arguments the timezone label for as.POSIXct   and as.POSIXlt is different in the example above ("HST" and "HST10")

> as.POSIXlt(firstjan)

[1] "2006-01-01 UTC"
> as.POSIXlt(firstjan,tz="HST10")

[1] "2006-01-01 UTC"   It still does not attach a timezone if the input is a string   representing a date (like in the first example).

> Sys.time()

[1] "2006-09-05 23:05:48 W. Europe Daylight Time"
> as.POSIXct(Sys.time(),tz=Sys.timezone())
[1] "2006-09-05 23:06:06 W. Europe Daylight Time"
> as.POSIXlt(Sys.time(),tz=Sys.timezone())
[1] "2006-09-05 22:06:11 Eur"

-- 
Erich Neuwirth, University of Vienna
Faculty of Computer Science
Computer Supported Didactics Working Group
Visit our SunSITE at http://sunsite.univie.ac.at
Phone: +43-1-4277-39464 Fax: +43-1-4277-39459

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel
Received on Thu Sep 07 18:39:02 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 Thu 07 Sep 2006 - 11:43:01 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.