Change 34717 by [EMAIL PROTECTED] on 2008/11/04 09:05:12
Integrate:
[ 34704]
Integrate:
[ 32728]
Subject: [PATCH] 64-bit fix for Time::Local
From: "Jan Dubois" <[EMAIL PROTECTED]>
Date: Thu, 20 Dec 2007 10:18:52 -0800
Message-ID: <[EMAIL PROTECTED]>
[ 34699]
Upgrade to Time::Local 1.1901.
Affected files ...
... //depot/maint-5.8/perl/lib/Time/Local.pm#10 integrate
... //depot/maint-5.8/perl/lib/Time/Local.t#11 integrate
Differences ...
==== //depot/maint-5.8/perl/lib/Time/Local.pm#10 (text) ====
Index: perl/lib/Time/Local.pm
--- perl/lib/Time/Local.pm#9~32319~ 2007-11-14 15:26:31.000000000 -0800
+++ perl/lib/Time/Local.pm 2008-11-04 01:05:12.000000000 -0800
@@ -7,7 +7,7 @@
use integer;
use vars qw( $VERSION @ISA @EXPORT @EXPORT_OK );
-$VERSION = '1.18';
+$VERSION = '1.1901';
@ISA = qw( Exporter );
@EXPORT = qw( timegm timelocal );
@@ -29,17 +29,17 @@
use constant SECS_PER_HOUR => 3600;
use constant SECS_PER_DAY => 86400;
-my $MaxInt = ( ( 1 << ( 8 * $Config{intsize} - 2 ) ) -1 ) * 2 + 1;
-my $MaxDay = int( ( $MaxInt - ( SECS_PER_DAY / 2 ) ) / SECS_PER_DAY ) - 1;
-
+my $MaxInt;
if ( $^O eq 'MacOS' ) {
# time_t is unsigned...
- $MaxInt = ( 1 << ( 8 * $Config{intsize} ) ) - 1;
+ $MaxInt = ( 1 << ( 8 * $Config{ivsize} ) ) - 1;
}
else {
- $MaxInt = ( ( 1 << ( 8 * $Config{intsize} - 2 ) ) - 1 ) * 2 + 1;
+ $MaxInt = ( ( 1 << ( 8 * $Config{ivsize} - 2 ) ) - 1 ) * 2 + 1;
}
+my $MaxDay = int( ( $MaxInt - ( SECS_PER_DAY / 2 ) ) / SECS_PER_DAY ) - 1;
+
# Determine the EPOC day for this machine
my $Epoc = 0;
if ( $^O eq 'vos' ) {
@@ -68,7 +68,7 @@
return $_[3] + (
$Cheat{ pack( 'ss', @_[ 4, 5 ] ) } ||= do {
my $month = ( $_[4] + 10 ) % 12;
- my $year = $_[5] + 1900 - $month / 10;
+ my $year = ( $_[5] + 1900 ) - ( $month / 10 );
( ( 365 * $year )
+ ( $year / 4 )
@@ -99,12 +99,6 @@
}
unless ( $Options{no_range_check} ) {
- if ( abs($year) >= 0x7fff ) {
- $year += 1900;
- croak
- "Cannot handle date ($sec, $min, $hour, $mday, $month,
*$year*)";
- }
-
croak "Month '$month' out of range 0..11"
if $month > 11
or $month < 0;
==== //depot/maint-5.8/perl/lib/Time/Local.t#11 (xtext) ====
Index: perl/lib/Time/Local.t
--- perl/lib/Time/Local.t#10~30203~ 2007-02-10 14:04:40.000000000 -0800
+++ perl/lib/Time/Local.t 2008-11-04 01:05:12.000000000 -0800
@@ -9,6 +9,7 @@
use strict;
+use Config;
use Test::More;
use Time::Local;
@@ -73,13 +74,13 @@
$neg_epoch_ok = 0; # time_t is unsigned
}
+my $epoch_is_64 = eval { $Config{ivsize} == 8 && ( gmtime 2**40 )[5] == 34912
};
+
my $tests = (@time * 12);
$tests += @neg_time * 12;
$tests += @bad_time;
$tests += @years;
-$tests += 10;
-$tests += 2 if $ENV{PERL_CORE};
-$tests += 8 if $ENV{MAINTAINER};
+$tests += 23;
plan tests => $tests;
@@ -192,7 +193,24 @@
is($@, '', 'no error with leap day of 1996 (year passed as 96)');
}
-if ($ENV{MAINTAINER}) {
+SKIP:
+{
+ skip 'These tests require a system with 64-bit time_t.', 3
+ unless $epoch_is_64;
+
+ is( timegm( 8, 14, 3, 19, 0, ( 1900 + 138 ) ), 2**31,
+ 'can call timegm for 2**31 epoch seconds' );
+ is( timegm( 16, 28, 6, 7, 1, ( 1900 + 206 ) ), 2**32,
+ 'can call timegm for 2**32 epoch seconds (on a 64-bit system)' );
+ is( timegm( 16, 36, 0, 20, 1, ( 34912 + 1900 ) ), 2**40,
+ 'can call timegm for 2**40 epoch seconds (on a 64-bit system)' );
+}
+
+SKIP:
+{
+ skip 'These tests only run for the package maintainer.', 8
+ unless $ENV{MAINTAINER};
+
require POSIX;
local $ENV{TZ} = 'Europe/Vienna';
@@ -246,14 +264,20 @@
'hour is 2 when given 2:00 AM on Europe/London date change' );
}
-if ($ENV{PERL_CORE}) {
- package test;
- require 'timelocal.pl';
-
- # need to get ok() from main package
- ::is(timegm(0,0,0,1,0,80), main::timegm(0,0,0,1,0,80),
- 'timegm in timelocal.pl');
+SKIP:
+{
+ skip 'These tests are only run when $ENV{PERL_CORE} is true.', 2
+ unless $ENV{PERL_CORE};
+
+ {
+ package test;
+ require 'timelocal.pl';
+
+ # need to get ok() from main package
+ ::is(timegm(0,0,0,1,0,80), main::timegm(0,0,0,1,0,80),
+ 'timegm in timelocal.pl');
- ::is(timelocal(1,2,3,4,5,88), main::timelocal(1,2,3,4,5,88),
- 'timelocal in timelocal.pl');
+ ::is(timelocal(1,2,3,4,5,88), main::timelocal(1,2,3,4,5,88),
+ 'timelocal in timelocal.pl');
+ }
}
End of Patch.