From ripley@stats.ox.ac.uk  Thu Apr 18 14:24:00 2002
From: ripley@stats.ox.ac.uk (ripley@stats.ox.ac.uk)
Date: Thu, 18 Apr 2002 14:24:00 +0100 (BST)
Subject: [Rd] strptime mysteriously adds a day - 0S-specific: Linux and
 Windows (so far) (PR#1466)
In-Reply-To: <Pine.LNX.4.31.0204181353250.32748-100000@gannet.stats>
Message-ID: <Pine.LNX.4.31.0204181421170.3919-100000@gannet.stats>

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. I'm not sure why glibc does this when the tm_year field is not

Well, I thought that was it, but as 1900 was not a leap year, it's
stranger still.

> being set, but it confidently says this is day 101 of the year, and that's
> the result you get.

(For 11 April, BTW.)

> The only portable workaround is to give the year: there is (at least in
> R-devel) a warning in the help file about this.
>
> --
> Brian D. Ripley,                  ripley@stats.ox.ac.uk
> Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
> University of Oxford,             Tel:  +44 1865 272861 (self)
> 1 South Parks Road,                     +44 1865 272860 (secr)
> Oxford OX1 3TG, UK                Fax:  +44 1865 272595
>
> -.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
> 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
> _._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._._
>

-- 
Brian D. Ripley,                  ripley@stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272860 (secr)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595

-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
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 Windows (so far) (PR#1466)
ripley@stats.ox.ac.uk