diff options
author | Steve Peters <steve@fisharerojo.org> | 2007-01-23 18:43:50 +0000 |
---|---|---|
committer | Steve Peters <steve@fisharerojo.org> | 2007-01-23 18:43:50 +0000 |
commit | bd4bdc1b706adf59396553c80fb9ab9eca754834 (patch) | |
tree | 0a018e35c703e4213789f3815e15b613e9964e9d /lib/Time | |
parent | 0dae80a28977a140e2612895990f004c2224ae10 (diff) | |
download | perl-bd4bdc1b706adf59396553c80fb9ab9eca754834.tar.gz |
Fix to Time::Local to fix problems with leap year calculation.
p4raw-id: //depot/perl@29936
Diffstat (limited to 'lib/Time')
-rw-r--r-- | lib/Time/Local.pm | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/lib/Time/Local.pm b/lib/Time/Local.pm index 528f2300c4..7347244494 100644 --- a/lib/Time/Local.pm +++ b/lib/Time/Local.pm @@ -91,6 +91,9 @@ sub _timegm { sub timegm { my ( $sec, $min, $hour, $mday, $month, $year ) = @_; + # Need to check leap year before altering the value + my $leap_year = _is_leap_year($year) + if ( $year >= 1000 ) { $year -= 1900; } @@ -111,7 +114,7 @@ sub timegm { my $md = $MonthDays[$month]; ++$md - if $month == 1 && _is_leap_year($year); + if $month == 1 && $leap_year; croak "Day '$mday' out of range 1..$md" if $mday > $md or $mday < 1; croak "Hour '$hour' out of range 0..23" if $hour > 23 or $hour < 0; |