[Rd] The presence/absence of `zone` in POSIXlt depending on time zone as a cause of possible inconsistences?
IAGO GINÉ VÁZQUEZ
|@g|ne @end|ng |rom p@@jd@org
Fri Oct 23 19:03:37 CEST 2020
Dear all,
I have just detected what seems a minor inconsistence with data types. If one unlists a POSIXlt time with GMT zone gets a numeric vector, since the POSIXlt list has no `zone` element, while if one unlists a POSIXlt time with a non GMT zone (also non specifying tz if the Sys.timezone is not GMT) gets a character vector due to including the `zone` element.
> x <- as.POSIXlt(Sys.time(), "GMT")
> (y <- unlist(x))
sec min hour mday mon year wday yday isdst
54.99715 26.00000 16.00000 23.00000 9.00000 120.00000 5.00000 296.00000 0.00000
> str(y)
Named num [1:9] 55 26 16 23 9 ...
- attr(*, "names")= chr [1:9] "sec" "min" "hour" "mday" ...
> x <- as.POSIXlt(Sys.time(), "CET")
> (y <- unlist(x))
sec min hour mday mon year wday yday
"19.5111262798309" "27" "18" "23" "9" "120" "5" "296"
isdst zone gmtoff
"1" "CEST" "7200"
> str(y)
Named chr [1:11] "19.5111262798309" "27" "18" "23" "9" "120" "5" "296" "1" "CEST" "7200"
- attr(*, "names")= chr [1:11] "sec" "min" "hour" "mday" ...
Is it expected? Why do not include always `zone` as an element of POSIXlt? Should POSIXlt objects be unlisted in a different way?
Thank you!
Best regards,
Iago
PS: I was using R 4.0.3. I don't know if this behaviour already changed in R-devel. Excuse me in that case.
[[alternative HTML version deleted]]
More information about the R-devel
mailing list