Here's a new patch for Time::Local that dies if it detects that it is
looping:
work% perl -wle 'use Time::Local; print timegm(8, 14, 3, 19, 11, 997)'
Couldn't handle date (8, 14, 3, 19, 11, 997) at -e line 1
work%
Under Linux here, it handles all dates in the years 1970 thru 2038
(70-99, 00-38) and dies for all other years. I don't try to address
the fact that strange values are returned for dates in '38 from
February onwards: the 31-bit epoch ends at 03:14:07 19th Jan 2038.
p5p-msgid:
199710030030.BAA17372@crypt.compulink.co.uk
@g = gmtime($guess);
$year += $YearFix if $year < $epoch;
$lastguess = "";
+ $counter = 0;
while ($diff = $year - $g[5]) {
+ croak "Couldn't handle date (".join(", ",@_).")" if ++$counter > 255;
$guess += $diff * (363 * $DAY);
@g = gmtime($guess);
if (($thisguess = "@g") eq $lastguess){
$lastguess = $thisguess;
}
while ($diff = $month - $g[4]) {
+ croak "Couldn't handle date (".join(", ",@_).")" if ++$counter > 255;
$guess += $diff * (27 * $DAY);
@g = gmtime($guess);
if (($thisguess = "@g") eq $lastguess){