atoomic / perl-TimeDate

time & date parsing and formatting perl library
http://search.cpan.org/dist/TimeDate/
1 stars 4 forks source link

Date::Parse::str2time maps date in 1963 to 2063 [rt.cpan.org #84075] #12

Open atoomic opened 4 years ago

atoomic commented 4 years ago

Migrated from rt.cpan.org#84075 (status was 'new')

Requestors:

Attachments:

From keith.s.thompson@gmail.com on 2013-03-19 18:37:42 :

The Date::Parse::str2time function, given a string representing a date in 
1963 such as "1963-12-31 23:59:59 UTC", returns a value denoting a date 
exactly 100 years later. Similar strings representing dates in 1964 or 
later are handled correctly. (I wonder if the relevant year is 50 years 
before the current year; that's just a guess.)

The attached test script demonstrates the bug, and includes the output I 
got after the __END__ marker; the output shows the version of Perl, of 
the Date::Parse module, and of my system (64-bit Linux).

The strptime() function works correctly for the same input strings.
Keith-S-Thompson commented 4 years ago

A new test confirms that the cutoff is 50 years before the current year. A modified version of the script shows that str2time("1970-12-31 23:59:59 UTC") yields Wed Dec 31 23:59:59 2070, and str2time("1971-01-01 00:00:00 UTC") yields Fri Jan 1 00:00:00 1971.

atoomic commented 4 years ago

@Keith-S-Thompson I've PR #39 pending to fix this issue I'm waiting to get maintenance permission in order to release a fix and take care of the pending cases

Keith-S-Thompson commented 4 years ago

I think the problem is the sliding 50-year window documented for Time::Local::timegm, along with the Date::Parse's unnecessary subtraction of 1900 from the year, which was explicitly given as 4 digits. (You probably already knew this.)