Full_Name: John Brzustowski Version: R-devel-trunk OS: linux (problem under Windows too) Submission from: (NULL) (74.101.124.238)
(This bug was discovered by Phil Taylor, Acadia University.) I'm not sure from reading the documentation whether strptime(x, "%j") is meant to be supported, but if so, there is a bug which prevents it from working on the first day of months after January: > strptime(31:33, "%j") [1] "2007-01-31" NA "2007-02-02" # the full extent of R's taunting strptime(1 + cumsum(c(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30)), "%j") [1] NA NA NA NA NA NA NA NA NA NA NA > The problem is an edge-case comparison in datetime.c:glibc_fix(). This generates a date like "Jan 32", which validate_tm() catches and NAs. (Values of field tm->tm_yday start at 0, not 1.) ================================================================================= PATCH: --- R/src/main/datetime.c (revision 40860) +++ R/src/main/datetime.c (working copy) @@ -796,7 +796,7 @@ if(tm->tm_yday != NA_INTEGER) { /* since we have yday, let that take precedence over mon/mday */ int yday = tm->tm_yday, mon = 0; - while(yday > (tmp = days_in_month[mon] + + while(yday >= (tmp = days_in_month[mon] + ((mon==1 && isleap(1900+tm->tm_year))? 1 : 0))) { yday -= tmp; mon++; ______________________________________________ R-devel@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-devel