in reply to Re^3: Date conversion in perl?
in thread Date conversion in perl?

ww@GIG:~$ perl -wle 'print scalar(localtime(20100302165019));' Wed Dec 31 18:59:59 1969 ww@GIG:~$ perl -wle 'print scalar(localtime(20100302165219));' Wed Dec 31 18:59:59 1969 ^ ww@GIG:~$ perl -wle 'print scalar(localtime(20100305165219));' Wed Dec 31 18:59:59 1969 ^ ww@GIG:~$ perl -wle 'print scalar(localtime(23100305165219));' Wed Dec 31 18:59:59 1969 ^

32bit 5.10 Linux

Replies are listed 'Best First'.
Re^5: Date conversion in perl?
by bart (Canon) on Mar 03, 2010 at 14:11 UTC
    FYI that date, 1 second before epoch, corresponds with a time value -1 (hex FFFFFFFF) which is commonly used as an overflow value for integer arithmetic.
Re^5: Date conversion in perl?
by ikegami (Patriarch) on Mar 03, 2010 at 15:59 UTC

    It's a different failure mode, but it's still failing by returning the date for -1 instead of returning undef.

    I imagine that some of the work in this area is done by the underlying C library, so you can expect differences between systems.

    I believe that might also be changed in 5.12 to avoid the year 2038 overflow.

    Update: Confirmed:

    $ /usr/bin/perl -le'print scalar localtime "201003031234"' Wed Dec 31 18:59:59 1969 $ ./perl -le'print scalar localtime "201003031234"' Fri Jul 14 19:20:34 8339