[R] Rounding in date.mdy from library(date)
Thomas Lumley
thomas at biostat.washington.edu
Mon Jan 3 18:10:06 CET 2000
On Mon, 3 Jan 2000, BXC (Bendix Carstensen) wrote:
> The date library contains a function date.mdy that converts a number
> D to the date (month,date,year as a list) at D days after 1 Jan 1960.
> This a convention that fits in with SASs.
>
> The logic would be that the result was the date at D days after
> 1 Jan 1960 00:00:00 (which is a POINT in time as opposed to a date which
> is an interval), so that any D with 2<=D<3 was rounded to 3 Jan 1960
> and so on. This is because at any time D days (i.e. D*24h) after
> 1.1.1960:00:00 with 2<=D<3 we would call the date "3 Jan 1960".
I think the date package is only intended to handle integers. This is
partly because date.mdy is _not_ a function for converting numbers to
dates, it is a function for converting dates to a printable form.
If you look at as.date() the truncation is already done there,
R> as.date(0)
[1] 1Jan60
R> as.date(0.9)
[1] 1Jan60
so a bona fide date object will always have an integer as the time since
1/1/1960. In that sense the workaround is to only use date.mdy on dates,
not on numbers.
I agree that it might be worth extending date to allow times in
addition to dates (in which case it probably would have to have
information on time zones as well). The tricky part would be parsing
time information in character form, but there is probably GNU code for
this.
-thomas
Thomas Lumley
Assistant Professor, Biostatistics
University of Washington, Seattle
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
r-help mailing list -- Read http://www.ci.tuwien.ac.at/~hornik/R/R-FAQ.html
Send "info", "help", or "[un]subscribe"
(in the "body", not the subject !) To: r-help-request at stat.math.ethz.ch
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
More information about the R-help
mailing list