OK.  Good point.

Note that that article was written 4 years ago
when R was at version 1.9 and POSIXt did not fully support
subseconds.  At that time, POSIXct could represent subseconds
internally but it was not used as POSIXlt did not yet support it
and that and the associated digits.sec option did not come until
R version 2.3, released two years after the article was written.

Try setting the digits.secs option before you run the command
like this:

> options(digits.secs = 3)
> dp <- Sys.time()
> dp-as.POSIXct(format(dp,tz="GMT"))
Time difference of -5 hours

On Feb 17, 2008 3:50 PM,  <[EMAIL PROTECTED]> wrote:
>
> Hi Gabo,
>
> FAQ 7.31 does not apply to this. "numeric" in R is 64bit which is large eno=
> ugh to handle this.
>
> I
> figured out the cause is that Sys.time() gives millisecond value while
> b<-as.POSIXct(format(a,tz=3D"GMT")) cuts off that part.=20
>
> Then of course a-b is not 5 hours!
>
> Do it again with "options(digits=3D22)" and you will see what actually happ=
> ened there.
>
> The recommended code from R News is not aware the truth that POSIXlt can re=
> present sub-second time.
>
> Cheers,
>
> B
> _________________________________________________________________
> Helping your favorite cause is as easy as instant messaging.=A0You IM, we g=
> ive.
>
>        [[alternative HTML version deleted]]
>
> ______________________________________________
> R-devel@r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>

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

Reply via email to