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?

>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.


-- 
________________________________________
Craig A. Berry
mailto:[EMAIL PROTECTED]

"... getting out of a sonnet is much more
 difficult than getting in."
                 Brad Leithauser

Reply via email to