On Thu, May 22, 2008 at 3:07 PM, Craig A. Berry <[EMAIL PROTECTED]> wrote: > At 1:50 PM -0500 5/22/08, Steve Peters wrote: > >> >> > Here's VMS: >>> >>> $ perl -MTestInit -"MTime::Piece" -"E" "say join '|', >>> Time::Piece::_strptime('2001-2-29 12:34:56', '%Y-%m-%d %H:%M:%S');" >>> Error parsing time at -e line 1. >>> >>> Here's Mac OS X: >>> >>> % ./perl -MTestInit -"MTime::Piece" -E "say join '|', >>> Time::Piece::_strptime('2001-2-29 12:34:56', '%Y-%m-%d %H:%M:%S');" >>> 56|34|12|1|2|101|4|59|0|0|0 >>> >>> If I'm reading this right, Mac OS X (and probably other BSDs) is >>> interpreting this as the first of March, which doesn't make much >>> sense to me, but may have a rationale behind it. In any case, >>> Time::Piece seems to depend on this non-portable behavior, and even, >>> as John noted, to be specifically testing for it. >>> >> >>Actually, there isn't any non-portable stuff happening regarding >>dates. The _strptime routine is supposed to see 2001-2-29 and realize >>that you really mean 2001-3-1. > > Why on earth would it think that? Is 2001-2-30 interpreted as 2001-3-2? >
Actually, yes, it seems to. [EMAIL PROTECTED]:~/perl-current$ ./perl -Ilib -"MTime::Piece" -"E" "say join '|', Time::Piece::_strptime('2001-2-30 12:34:56', '%Y-%m-%d %H:%M:%S');" 56|34|12|2|2|101|5|60|0|0|0 I get identical answers on Win32, Solaris, Cygwin and Linux. >>For some reason, the code works pretty >>much everywhere else, but HP-UX and VMS. > > Because it's not the same code. As far as I can tell, it's just > calling the C library's strptime() and however that interprets > 2001-2-29 determines what happens.* Since 2001-2-29 is an invalid > date, returning an error seems to me like the right thing to do, and > that's what VMS and apparently HP-UX do. But different implementors > have had different ideas, and as I mentioned before, no standard I > can find says anything about what conditions should be considered > error conditions. For systems that guess that you meant something > other than what you said, is there any documentation that describes > the intention? Do we even know that interpreting 2001-2-29 as > 2001-3-1 is intentional and not just an untrapped error? > > * The exception to that is that on Win32 the PowerDog strptime() > implementation is used by Time::Piece, and this is the same > implementation used by the BSDs. > It would seem to me that an error is correct, but, obviously, that's not how they were implemented anywhere except on HP-UX, VMS, and Tru64 (see http://www.nntp.perl.org/group/perl.daily-build.reports/2008/05/msg55675.html). So, saying its an untrapped error seems unlikely. It just seems that HP-UX, VMS, and Tru64 are the exception rather than the rule. Steve Peters [EMAIL PROTECTED]