develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [ID 19991112.005] perl 5.005_03 i686-linux-thread localtime() is not Y2K clean

Thread Previous
From:
Chip Turner
Date:
November 12, 1999 18:42
Subject:
Re: [ID 19991112.005] perl 5.005_03 i686-linux-thread localtime() is not Y2K clean
Message ID:
m3emdvf6vk.fsf@flash.zfx.com
Phil Stracchino <root@atrium.cardima.com> writes:

>         $submitdate = $dblist{'submitdate'}->{$ticket};
>         ($junk, $min, $hour, $mday, $junk, $year, $junk, $junk, $junk) = localtime($submitdate);
>         $weekday = (Sun,Mon,Tue,Wed,Thu,Fri,Sat)[(localtime($submitdate))[6]];
>         $month = (Jan,Feb,Mar,Apr,May,Jun,Jul,Aug,Sep,Oct,Nov,Dec)[(localtime($submitdate))[4]];
>         $date = sprintf ("%02d:%02d %s %s %d, %04d", $hour, $min, $weekday, $month, $mday, $year);
> 
> The resulting formatted date:  17:32 Fri Nov 12, 0099
> Adding 5 years worth of seconds to the value passed to localtime() results
> in a year of 0104.

Not a bug.  Read:

perldoc -f localtime

for details.  You also might want to check strftime in the POSIX
package for more robust date printing.

Chip

-- 
Chip Turner                   chip@ZFx.com
                              Programmer, ZFx, Inc.  www.zfx.com
                              PGP key available at wwwkeys.us.pgp.net

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About