Subject: | Error when month is out of range |
Date: | Mon, 7 Apr 2008 14:21:34 +0200 |
To: | <bug-Time-Local [...] rt.cpan.org> |
From: | "Lars Danielsen" <Lars.Danielsen [...] datagraf.dk> |
Hello
I think I have found a bug in time-local.
Pleace consider this code:
use strict;
use Time::Local;
my $int = Time::Local::timelocal_nocheck(59, 59, 23, 31, 11, 100);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime
$int;
print "$year/$mon/$mday $hour:$min:$sec"; #returns 100/11/31 23:59:59,
being one second before newyear 2000
print "\n";
my $int = Time::Local::timelocal_nocheck(61, 59, 23, 31, 11, 100);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime
$int;
print "$year/$mon/$mday $hour:$min:$sec"; #returns 101/0/1 0:0:1, being
one second after newyear 2001, since seconds are invalid, next year is
reached
print "\n";
#same thing for minutes, hours and dates, but for months, it does not
add a year. The month is apparently set to $mon % 12 somewhere:
my $int = Time::Local::timelocal_nocheck(59, 59, 23, 31, 12, 100);
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime
$int;
print "$year/$mon/$mday $hour:$min:$sec"; #returns 100/0/31 23:59:59,
not 101/0/31 23:59:59 as expected
When dec 32. 2000 is parsed as jan 1. 2001, I suppose that [13th month]
1. 2000 should be jan 1. 2001 as well. Wouldn't you agree?
Cordially
Lars Danielsen
Developer
Tlf: 87 95 55 55
Direkte: 87 95 55 90
Mobil: 30 20 30 41