[sf-perl] localtime bug
Ray Baxter
ray at warmroom.com
Thu Apr 13 01:27:36 PDT 2006
Ray Baxter wrote:
> S A wrote:
>
>> Anyone else have trouble with localtime behaving funny? For some odd
>> reason Time::Local is an hour off when it interprets this particular set of
>> numbers
>>
>> [samshey at amshey samshey]$ cat test
>> #!/usr/local/bin/perl -w
>>
>> use strict;
>> use Time::Local;
>>
>> #timelocal($secs, $mins, $hrs, $day, $month, $year)
>> my $time_start = timelocal(40, 59, 03, 02, 03, 06); # 3:59:40
>> my $time_end = timelocal(33, 00, 04, 02, 03, 06); # 4:00:33
>>
>> print "localtimes:\n";
>> print "timelocal start: $time_start (= " . localtime($time_start) . ")\n";
>> print "timelocal end: $time_end (= " . localtime($time_end) . ")\n";
>>
>> print "gm times:\n";
>> print "timelocal start: $time_start (= " . gmtime($time_start) . ")\n";
>> print "timelocal end: $time_end (= " . gmtime($time_end) . ")\n";
>>
>> exit;
>> [samshey at amshey samshey]$ perl test
>> localtimes:
>> timelocal start: 1143979180 (= Sun Apr 2 04:59:40 2006)
>> timelocal end: 1143975633 (= Sun Apr 2 04:00:33 2006)
>> gm times:
>> timelocal start: 1143979180 (= Sun Apr 2 11:59:40 2006)
>> timelocal end: 1143975633 (= Sun Apr 2 11:00:33 2006)
>>
If you grab the latest Time::Local from cpan, this bug is fixed.
[ray at stork ray]$ perl test
localtimes:
timelocal start: 1143975580 (= Sun Apr 2 03:59:40 2006)
timelocal end: 1143975633 (= Sun Apr 2 04:00:33 2006)
gm times:
timelocal start: 1143975580 (= Sun Apr 2 10:59:40
2006)
Ray
More information about the SanFrancisco-pm
mailing list