From gb@stat.umu.se  Thu Apr 18 14:24:43 2002
From: gb@stat.umu.se (=?iso-8859-1?Q?G=F6ran_Brostr=F6m?=)
Date: Thu, 18 Apr 2002 15:24:43 +0200 (CEST)
Subject: [Rd] strptime mysteriously adds a day - 0S-specific: Linux and
 (PR#1467)
In-Reply-To: <200204181308.PAA06220@pubhealth.ku.dk>
Message-ID: <Pine.LNX.4.44.0204181513030.5841-100000@tal.stat.umu.se>

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

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

-- 
 Gran Brostrm                      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
_._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._


[Rd] strptime mysteriously adds a day - 0S-specific: Linux and (PR#1467)
=?iso-8859-1?Q?G=F6ran_Brostr=F6m?=