Subject: | str2time wrong date when no year specified |
Date: | Fri, 31 Jan 2014 10:31:43 +0000 |
To: | bug-TimeDate [...] rt.cpan.org |
From: | <honir999 [...] gmail.com> |
Parsing dates when no year specified, for a future month generates wrong year.
perl -e "use Date::Parse; print str2time('31 Jan');"
1391126400
i.e. Fri, 31 Jan 2014 00:00:00 GMT
but
perl -e "use Date::Parse; print str2time('1 Feb');"
1359676800
i.e. Fri, 01 Feb 2013 00:00:00 GMT
Wrong year: expected output 1391212800 i.e. Sat, 01 Feb 2014 00:00:00 GMT
Code causing the error is line 252, which is always subtracting 1 from the year for a future month when the year is undefined.
$year = ($month > $lt[4]) ? ($lt[5] - 1) : $lt[5]
unless(defined $year);
Date::Parse 2.30
perl, v5.8.8