Skip Menu |

This queue is for tickets about the Time-Piece CPAN distribution.

Report information
The Basics
Id: 36106
Status: resolved
Priority: 0/
Queue: Time-Piece

People
Owner: Nobody in particular
Requestors: HMBRAND [...] cpan.org
Cc:
AdminCc:

Bug Information
Severity: Critical
Broken in: (no value)
Fixed in: (no value)



Subject: Unportable behaviour for "2001-2-29 12:34:56"
t/07arith.........1/13 Error parsing time at /pro/3gl/CPAN/Time- Piece-1.13/blib/lib/Time/Piece.pm line 615. # Looks like you planned 13 tests but only ran 10. # Looks like your test died just after 10. t/07arith......... Dubious, test returned 255 (wstat 65280, 0xff00) Failed 3/13 subtests 2001 was not a leap year, so it's not a valid time. The standard for strptime is silent about what level of validation, if any, should be done on the incoming time string. Some systems /might/ read this as 2001-03-01, which makes no sense to me. In any case, Time::Piece seems to depend on this non-portable behavior, and even to be specifically testing for it. *IF* testing for non-portable behaviour, at least do it subtle, and don't croak. This test breaks all builds on VMS and HP-UX
From: GAAS [...] cpan.org
I've provided this patch to Matt. | Thanks. Applied in svn as r80.
==== //depot/Piece.pm#2 - /Users/gisle/camel/src/cpan/T/Time/Time-Piece/main/Piece.pm ==== Index: Piece.pm --- Piece.pm.~1~ Tue May 6 22:00:41 2008 +++ Piece.pm Tue May 6 22:00:41 2008 @@ -607,12 +607,8 @@ $final_month = $final_month % 12; } - my $string = ($time->year + $num_years) . "-" . - ($final_month + 1) . "-" . - ($time->mday) . " " . $time->hms; - my $format = "%Y-%m-%d %H:%M:%S"; - #warn("Parsing string: $string\n"); - my @vals = _strptime($string, $format); + my @vals = _mini_mktime($time->sec, $time->min, $time->hour, + $time->mday, $final_month, $time->year - 1900 + $num_years); # warn(sprintf("got vals: %d-%d-%d %d:%d:%d\n", reverse(@vals))); return scalar $time->_mktime(\@vals, $time->[c_islocal]); } ==== //depot/Piece.xs#5 - /Users/gisle/camel/src/cpan/T/Time/Time-Piece/main/Piece.xs ==== Index: Piece.xs --- Piece.xs.~1~ Tue May 6 22:00:41 2008 +++ Piece.xs Tue May 6 22:00:41 2008 @@ -915,3 +915,37 @@ PUSHs(sv_2mortal(newSViv(0))); /* islocal */ PUSHs(sv_2mortal(newSViv(0))); + +void +_mini_mktime(int sec, int min, int hour, int mday, int mon, int year) + PREINIT: + struct tm mytm; + time_t t; + PPCODE: + t = 0; + mytm = *gmtime(&t); + + mytm.tm_sec = sec; + mytm.tm_min = min; + mytm.tm_hour = hour; + mytm.tm_mday = mday; + mytm.tm_mon = mon; + mytm.tm_year = year; + + my_mini_mktime(&mytm); + + EXTEND(SP, 11); + PUSHs(sv_2mortal(newSViv(mytm.tm_sec))); + PUSHs(sv_2mortal(newSViv(mytm.tm_min))); + PUSHs(sv_2mortal(newSViv(mytm.tm_hour))); + PUSHs(sv_2mortal(newSViv(mytm.tm_mday))); + PUSHs(sv_2mortal(newSViv(mytm.tm_mon))); + PUSHs(sv_2mortal(newSViv(mytm.tm_year))); + PUSHs(sv_2mortal(newSViv(mytm.tm_wday))); + PUSHs(sv_2mortal(newSViv(mytm.tm_yday))); + /* isdst */ + PUSHs(sv_2mortal(newSViv(0))); + /* epoch */ + PUSHs(sv_2mortal(newSViv(0))); + /* islocal */ + PUSHs(sv_2mortal(newSViv(0))); End of Patch.
Appears long resolved.