[Rd] POSIXt oddness at end of 1969
William Dunlap
wdunlap at tibco.com
Wed Apr 17 22:10:58 CEST 2013
A user here noticed the following difference between Linux and Windows versions
of R-2.15.3 (and R-3.0.0, I think) when using times within a second of the end of 1969:
f <- function (sec = -1)
{
x1 <- as.POSIXct(c(2 * sec, sec, 0), origin = "1970-01-01", tz = "UTC")
x2 <- as.POSIXlt(x1)
x3 <- as.POSIXct(x2, origin = "1970-01-01", tz = "UTC")
list(x1 = x1, x2 = x2, x3 = x3)
}
On Windows I get:
> f(-1)
$x1
[1] "1969-12-31 23:59:58 UTC"
[2] "1969-12-31 23:59:59 UTC"
[3] "1970-01-01 00:00:00 UTC"
$x2
[1] "1969-12-31 23:59:58 UTC"
[2] "1969-12-31 23:59:59 UTC"
[3] "1970-01-01 00:00:00 UTC"
$x3
[1] "1969-12-31 23:59:58 UTC"
[2] "1969-12-31 23:59:59 UTC"
[3] "1970-01-01 00:00:00 UTC"
On Linux I get an NA in x3 for 1 second before 1970:
> f(-1)
$x1
[1] "1969-12-31 23:59:58 UTC"
[2] "1969-12-31 23:59:59 UTC"
[3] "1970-01-01 00:00:00 UTC"
$x2
[1] "1969-12-31 23:59:58 UTC"
[2] "1969-12-31 23:59:59 UTC"
[3] "1970-01-01 00:00:00 UTC"
$x3
[1] "1969-12-31 23:59:58 UTC"
[2] NA
[3] "1970-01-01 00:00:00 UTC"
On Windows, sessionInfo() is
R version 2.15.3 (2013-03-01)
Platform: x86_64-w64-mingw32/x64 (64-bit)
locale:
[1] LC_COLLATE=English_United States.1252 LC_CTYPE=English_United States.1252
[3] LC_MONETARY=English_United States.1252 LC_NUMERIC=C
[5] LC_TIME=English_United States.1252
attached base packages:
[1] stats graphics grDevices utils datasets methods base
On Linux, sessionInfo() is
> sessionInfo()
R version 2.15.3 (2013-03-01)
Platform: x86_64-unknown-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com
More information about the R-devel
mailing list