[Rd] strptime mysteriously adds a day - 0S-specific: Linux and
Thu, 18 Apr 2002 15:24:43 +0200 (CEST)
On Thu, 18 Apr 2002 email@example.com wrote:
> On Thu, 18 Apr 2002, Martin Maechler wrote:
> > >>>>> "Jason" == Jason Turner <firstname.lastname@example.org> writes:
> > Jason> strptime() mysteriously adds a day to a date, unless the year
> > Jason> is specified. Tested on:
> > Jason> Linux (RedHat 6.0) - R version 1.4.1 and R-devel.
> > Jason> Windows - R version 1.4.1
> > Jason> Bug isn't found on OpenBSD, R version 1.4.1.
> > I confirm the bug (R-devel, Redhat 7.1)
> > To reproduce, it's sufficient to work with
> > "%d %B" or "%d %b" .
> > What happens is that January and February work okay, and all
> > months from March produce the problem,
> > e.g.
> > > strptime("28 Feb",format="%d %b")# ok
> >  "2002-02-28"
> > > strptime("19 March",format="%d %B")# wrong
> >  "2002-03-20"
> The issue is that an unspecified year is assumed *by the IS* to be 1900, a
> leap year.
Sorry, 1900 is not a leap year. Maybe glibc doesn't know that? :-)
However, 'cal 1900' (on Linux) gives a correct answer.
> I'm not sure why glibc does this when the tm_year field is not
> being set, but it confidently says this is day 101 of the year, and that's
> the result you get.
> The only portable workaround is to give the year: there is (at least in
> R-devel) a warning in the help file about this.
Göran Broström tel: +46 90 786 5223
professor fax: +46 90 786 6614
Department of Statistics http://www.stat.umu.se/egna/gb/
SE-90187 Umeå, Sweden e-mail: email@example.com
r-devel 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: firstname.lastname@example.org