From: Michael G. Schwern Date: Sat, 30 Jan 2010 09:41:59 +0000 (-0800) Subject: Add sanity checks for far, far distant dates. X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=e66590ee0c794dd404055173204d6a0057f5d90d;p=p5sagit%2Fp5-mst-13.2.git Add sanity checks for far, far distant dates. Can't go beyond y2**31 because of the 32 bit year Adds a test that we can make it to at least +/-2**52. This is the missing test for 455f2c6c92e42c1a9e31268cbd491ba661f99882 which kicked this whole thing off. Signed-off-by: Michael G. Schwern --- diff --git a/t/op/time.t b/t/op/time.t index 0f2dd66..baff462 100644 --- a/t/op/time.t +++ b/t/op/time.t @@ -6,7 +6,7 @@ BEGIN { require './test.pl'; } -plan tests => 44; +plan tests => 56; ($beguser,$begsys) = times; @@ -145,3 +145,26 @@ ok(gmtime() =~ /^(Sun|Mon|Tue|Wed|Thu|Fri|Sat)[ ] }; is($@, '', 'Ignore fractional time'); } + + +# Some sanity tests for the far, far future and far, far past +{ + my %time2year = ( + -2**52 => -142711421, + -2**48 => -8917617, + -2**46 => -2227927, + 2**46 => 2231866, + 2**48 => 8921556, + 2**52 => 142715360, + ); + + for my $time (sort keys %time2year) { + my $want = $time2year{$time}; + + my $have = (gmtime($time))[5] + 1900; + is $have, $want, "year check, gmtime($time)"; + + $have = (localtime($time))[5] + 1900; + is $have, $want, "year check, localtime($time)"; + } +}