Error in return value for as.Date() (PR#8669)

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Error in return value for as.Date() (PR#8669)

Full_Name: Tom Wainwright
Version: 2.2.1  (2005-12-20 r36812)
OS: Linux (SuSE 9.3)
Submission from: (NULL) (

The as.Date function returns erroneous result for certain values using a
day-of-year format.  First an example that works (last day of 1970):

> as.Date("1970.365", format="%Y.%j")
[1] "1970-12-31"

Next, a bad example (oops, 1970 wasn't a leap year).  Incrementing day by one
date ahead by 2 years 1 month:

> as.Date("1970.366", format="%Y.%j")
[1] "1972-01-31"
> as.Date("1970.366", format="%Y.%j") - as.Date("1970.365", format="%Y.%j")
Time difference of 396 days

The second example should probably return an NA as this is an invalid date.

[hidden email] mailing list