gb@stat.umu.se
2002-Apr-18 13:30 UTC
[Rd] strptime mysteriously adds a day - 0S-specific: Linux and (PR#1468)
On Thu, 18 Apr 2002 ripley@stats.ox.ac.uk wrote:> On Thu, 18 Apr 2002, Martin Maechler wrote: > > > >>>>> "Jason" == Jason Turner <jasont@indigoindustrial.co.nz> 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 > > [1] "2002-02-28" > > > strptime("19 March",format="%d %B")# wrong > > [1] "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. Göran> 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/ Umeå University SE-90187 Umeå, Sweden e-mail: gb@stat.umu.se -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.- 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: r-devel-request@stat.math.ethz.ch _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._