Bug#557738: libtimedate-perl: RFC2822 dates with 2-digit year are not parsed correctly (regression)

Vincent Lefevre vincent at vinc17.net
Sat Mar 13 09:47:57 UTC 2010


(I didn't see the reply because I was not subscribed to the bug.)

On 2009-11-29 23:14:25 +0100, Christian Hammers wrote:
> Am Sun, 29 Nov 2009 13:50:00 -0600
> schrieb Graham Barr <gbarr at pobox.com>:
> 
> > I disagree 2007 is the correct answer, 07 is ambiguous so expecting
> > 2007 is just as wrong as 1907 IMO.

In such a case, you should fix the documentation, as there are
examples with 2-digit years:

        Wed, 16 Jun 94 07:29:35 CST
        Thu, 13 Oct 94 10:13:13 -0700
        21/dec/93 17:05
        16 Nov 94 22:28:20 PST

(even though 2093 and 2094 haven't passed yet, users may want to deal
with dates in the future). Also, you should say that Date::Parse must
not be used to parse RFC2822 dates, or the user should first make sure
that the year is on 4 digits, e.g. with:

        $date =~ s/( [A-Z][a-z][a-z] +)(\d\d) /
          $1.($2 + ($2 < 50 ? 2000 : 1900))." "/e;

This is safe if used in a RFC2822 context, as RFC2822 makes 2-digit
years unambiguous.

-- 
Vincent Lefèvre <vincent at vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)





More information about the pkg-perl-maintainers mailing list