Skip Menu |

This queue is for tickets about the TimeDate CPAN distribution.

Report information
The Basics
Id: 124509
Status: open
Priority: 0/
Queue: TimeDate

People
Owner: Nobody in particular
Requestors: bitcardbmw [...] lsmod.de
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 2.30
Fixed in: (no value)



Subject: tests fails in 2020
similar to https://rt.cpan.org/Public/Bug/Display.html?id=124508 after 2020-01-01 $offset was shifting dates from 2002 to 2102 This trivial patch fixed it for me: Index: TimeDate-2.30/t/getdate.t =================================================================== --- TimeDate-2.30.orig/t/getdate.t +++ TimeDate-2.30/t/getdate.t @@ -156,7 +156,7 @@ Jul 22 10:00:00 UTC 2002 ;102733200 !; require Time::Local; -my $offset = Time::Local::timegm(0,0,0,1,0,70); +my $offset = Time::Local::timegm(0,0,0,1,0,1970); @data = split(/\n/, $data);
On 2018-02-21 06:13:18, bmwiedemann wrote: Show quoted text
> similar to https://rt.cpan.org/Public/Bug/Display.html?id=124508 > > after 2020-01-01 $offset was shifting dates from 2002 to 2102 > > This trivial patch fixed it for me: > > Index: TimeDate-2.30/t/getdate.t > =================================================================== > --- TimeDate-2.30.orig/t/getdate.t > +++ TimeDate-2.30/t/getdate.t > @@ -156,7 +156,7 @@ Jul 22 10:00:00 UTC 2002 ;102733200 > !; > > require Time::Local; > -my $offset = Time::Local::timegm(0,0,0,1,0,70); > +my $offset = Time::Local::timegm(0,0,0,1,0,1970); > > @data = split(/\n/, $data); >
Confirmed. Since today the test suite is failing. Proposed fix seems to work.
On 2019-12-31 20:49:34, SREZIC wrote: Show quoted text
> On 2018-02-21 06:13:18, bmwiedemann wrote:
> > similar to https://rt.cpan.org/Public/Bug/Display.html?id=124508 > > > > after 2020-01-01 $offset was shifting dates from 2002 to 2102 > > > > This trivial patch fixed it for me: > > > > Index: TimeDate-2.30/t/getdate.t > > =================================================================== > > --- TimeDate-2.30.orig/t/getdate.t > > +++ TimeDate-2.30/t/getdate.t > > @@ -156,7 +156,7 @@ Jul 22 10:00:00 UTC 2002 ;102733200 > > !; > > > > require Time::Local; > > -my $offset = Time::Local::timegm(0,0,0,1,0,70); > > +my $offset = Time::Local::timegm(0,0,0,1,0,1970); > > > > @data = split(/\n/, $data); > >
> > Confirmed. Since today the test suite is failing. Proposed fix seems > to work.
CPAN.pm users may use the following distroprefs file for automatic patching: https://github.com/eserte/srezic-cpan-distroprefs/blob/master/TimeDate.yml
Subject: [rt.cpan.org #124509]
Date: Fri, 10 Jan 2020 10:46:21 -0800
To: bug-TimeDate [...] rt.cpan.org
From: David Good <dgood [...] willingminds.com>


While it's true that the proposed fix allows the tests to succeed, it doesn't fix the underlying bug.  For example:

Show quoted text

# perl -MDate::Parse -e '$t = str2time("1970-01-01"); print "$t\n"; print gmtime($t) . "\n";'
3155788800
Wed Jan  1 08:00:00 2070

Am Fr 10. Jan 2020, 13:57:14, dgood@willingminds.com schrieb: Show quoted text
> # perl -MDate::Parse -e '$t = str2time("1970-01-01"); print "$t\n"; > print > gmtime($t) . "\n";' > 3155788800 > Wed Jan 1 08:00:00 2070
indeed the tests were incomplete and did not catch this problem. Attached a fix for this one and added test coverage.
Subject: TimeDate-fix2020.patch.txt
Index: TimeDate-2.30/t/cpanrt.t =================================================================== --- TimeDate-2.30.orig/t/cpanrt.t +++ TimeDate-2.30/t/cpanrt.t @@ -1,7 +1,7 @@ use Date::Format qw(time2str strftime); use Date::Parse qw(strptime str2time); -print "1..8\n"; +print "1..10\n"; my $i = 1; @@ -53,3 +53,11 @@ my $i = 1; print "not " if str2time('16 Oct 09') < 0; print "ok ", $i++, "\n"; } + +{ # https://rt.cpan.org/Public/Bug/Display.html?id=124509 year 2020 problem + print "# 1970-01-01 => 0\n"; + print "not " if str2time('1970-01-01') != 0; + print "ok ", $i++, "\n"; + print "not " if str2time('01 Jan 70') == 0; + print "ok ", $i++, "\n"; +} Index: TimeDate-2.30/lib/Date/Parse.pm =================================================================== --- TimeDate-2.30.orig/lib/Date/Parse.pm +++ TimeDate-2.30/lib/Date/Parse.pm @@ -195,7 +195,7 @@ sub { } } - $year -= 1900 if defined $year && $year > 1900; + $year -= 1900 if defined $year && $year > 2000; $zone += 3600 if defined $zone && $dst; $ss += "0.$frac" if $frac;
Any idea when a fix will be available via cpanm? Or can you please provide instructions on how to apply the patch? On Fri Jan 10 23:07:36 2020, https://bmwiedemann.zq1.de/ wrote: Show quoted text
> Am Fr 10. Jan 2020, 13:57:14, dgood@willingminds.com schrieb:
> > # perl -MDate::Parse -e '$t = str2time("1970-01-01"); print "$t\n"; > > print > > gmtime($t) . "\n";' > > 3155788800 > > Wed Jan 1 08:00:00 2070
> > indeed the tests were incomplete and did not catch this problem. > > Attached a fix for this one and added test coverage.