[R] How long is a day?

Prof Brian Ripley ripley at stats.ox.ac.uk
Wed Jul 2 08:15:20 CEST 2003


On Wed, 2 Jul 2003, Laimonis Kavalieris wrote:

> Why is 19 March, 1947 a little longer than one day?

A change from Daylight Savings Time in your time zone (unstated),
according to your OS.  Note, 0.04167 is exactly one hour, not `a little 
longer'.

>  x <-  as.POSIXct("1947-04-16")
> 
>  julian(x, origin = as.POSIXct("1947-03-20"))
> Time difference of 27 days
> 
>  julian(x, origin = as.POSIXct("1947-03-19"))
> Time difference of 28.04167 days
> 
>  > julian(x, origin = as.POSIXct("1947-03-18"))
> Time difference of 29.04167 days

You can just subtract dates.  In the UK

> x - as.POSIXct("1947-03-19")
Time difference of 27.95833 days

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595




More information about the R-help mailing list