Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Time-Local CPAN distribution.

Report information
The Basics
Id: 16165
Status: resolved
Priority: 0/
Queue: Time-Local

People
Owner: Nobody in particular
Requestors: ikegami [...] adaelis.com
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: (no value)
Fixed in: 1.12_01



Subject: month >= 12 doesn't add to year with _nocheck
The problem was discovered in 1.04, but I believe it still exists in 1.11. Test: use Time::Local qw/timelocal_nocheck/; print scalar( localtime( timelocal_nocheck( 0,0,0,1,0,5 )) ), "\n"; print scalar( localtime( timelocal_nocheck( 0,0,0,1,12,5 )) ), "\n"; Output: Sat Jan 1 00:00:00 2005 Sat Jan 1 00:00:00 2005 Expected Output: Sat Jan 1 00:00:00 2005 Sat Jan 1 00:00:00 2006 Possible patch: =sub _daygm { = $_[3] + ($Cheat{pack("ss",@_[4,5])} ||= do { = my $month = ($_[4] + 10) % 12; - my $year = $_[5] + 1900 - $month/10; + my $year = $_[5] + 1900 + ($_[4] + 10) / 12 - 1; = 365*$year + $year/4 - $year/100 + $year/400 + ($month*306 + 5)/10 - $Epoc = }); =}
On Mon Nov 28 14:16:24 2005, guest wrote: Show quoted text
> The problem was discovered in 1.04, but I believe it still exists in > 1.11. > > Test: > use Time::Local qw/timelocal_nocheck/; > print scalar( localtime( timelocal_nocheck( 0,0,0,1,0,5 )) ), "\n"; > print scalar( localtime( timelocal_nocheck( 0,0,0,1,12,5 )) ), "\n"; > > Output: > Sat Jan 1 00:00:00 2005 > Sat Jan 1 00:00:00 2005 > > Expected Output: > Sat Jan 1 00:00:00 2005 > Sat Jan 1 00:00:00 2006 > > Possible patch: > =sub _daygm { > = $_[3] + ($Cheat{pack("ss",@_[4,5])} ||= do { > = my $month = ($_[4] + 10) % 12; > - my $year = $_[5] + 1900 - $month/10; > + my $year = $_[5] + 1900 + ($_[4] + 10) / 12 - 1; > = 365*$year + $year/4 - $year/100 + $year/400 + ($month*306 + 5)/10 > - $Epoc > = }); > =}
Sorry for the slow response. This is similar to something that was proposed a couple years ago on the p5p list. Go to http://rt.perl.org/perlbug/ and search for ticket 31421 to read the discussion (unfortunately, it requires a guest login so I can't provide a direct URI). The gist of this was that Time::Local is really not intended to be a tool for date math. What it _does_ need is a doc patch explaining what the nocheck variants are for (which is speeding up operations with known good data).