From thomas.wainwright at noaa.gov  Wed Mar  8 23:17:55 2006
From: thomas.wainwright at noaa.gov (thomas.wainwright@noaa.gov)
Date: Wed,  8 Mar 2006 23:17:55 +0100 (CET)
Subject: [Rd] Error in return value for as.Date() (PR#8669)
Message-ID: <20060308221755.1852A199FD@slim.kubism.ku.dk>

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


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
moves
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.



[Rd] Error in return value for as.Date() (PR#8669)
thomas.wainwright@noaa.gov