This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix to Time::Local to fix problems with leap year calculation.
authorSteve Peters <steve@fisharerojo.org>
Tue, 23 Jan 2007 18:43:50 +0000 (18:43 +0000)
committerSteve Peters <steve@fisharerojo.org>
Tue, 23 Jan 2007 18:43:50 +0000 (18:43 +0000)
p4raw-id: //depot/perl@29936

lib/Time/Local.pm

index 528f230..7347244 100644 (file)
@@ -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;