> x<-as.POSIXct("1970-1-1", tz="UTC")-.5
> y<-as.POSIXct("1970-1-1", tz="UTC")+.5
> x==y
[1] FALSE  # of course
but x and y "appear" to be the same when formatted, even with extra
precision:
> format(x, format="%Y-%m-%d %H:%M:%OS2")
[1] "1970-01-01 00:00:00.50"
> format(y, format="%Y-%m-%d %H:%M:%OS2")
[1] "1970-01-01 00:00:00.50"

Formatted output is fine for integral difference points ...
> x<-as.POSIXct("1970-1-1", tz="UTC")-1
> y<-as.POSIXct("1970-1-1", tz="UTC")+1
> format(x, format="%Y-%m-%d %H:%M:%OS2")
[1] "1969-12-31 23:59:59.00"
> format(y, format="%Y-%m-%d %H:%M:%OS2")
[1] "1970-01-01 00:00:01.00"

... but seems to be a second "off" for non-integers:
> format(as.POSIXct("1970-1-1", tz="UTC")-1.5, format="%Y-%m-%d %H:%M:%OS2")
[1] "1969-12-31 23:59:59.50"   # a second later than expected
> format(as.POSIXct("1970-1-1", tz="UTC")-86400, format="%Y-%m-%d
%H:%M:%OS2")
[1] "1969-12-31 00:00:00.00"   # OK
> format(as.POSIXct("1970-1-1", tz="UTC")-86400.5, format="%Y-%m-%d
%H:%M:%OS2")
[1] "1969-12-31 00:00:00.50"   # why "after" previous time?

Bug, or user misunderstanding?
"R version 2.11.1 (2010-05-31)" on Windows
Thanks.
Dan Murphy

        [[alternative HTML version deleted]]

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to