Subject: | gmtime() failure. |
I am not getting the expected results from the gmtime() function. Consider the following coce:
----
#!/usr/bin/perl
use Time::Piece;
print "/bin/date: ", `/bin/date`;
$time = time;
$t = localtime($time);
print "localtime() results:\n";
print scalar $t, " (epoch: ", $t->epoch, ")\n";
print $t->strftime, "\n";
$gt = gmtime($time);
print "gmtime() results:\n";
print scalar $gt, " (epoch: ", $t->epoch, ")\n";
print $gt->strftime, "\n";
$ngt = $t->gmtime;
print "gmtime() from localtime()-generated Time::Piece:\n";
print scalar $ngt, "(epoch: ", $ngt->epoch, ")\n";
print $ngt->strftime, "\n";
----
Which produces the following output on my machine:
/bin/date: Thu Feb 6 16:50:00 EST 2003
localtime() results:
Thu Feb 6 16:50:00 2003 (epoch: 1044568200)
Thu, 06 Feb 2003 16:50:00 EST
gmtime() results:
Thu Feb 6 21:50:00 2003 (epoch: 1044568200)
Thu, 06 Feb 2003 21:50:00 EST
gmtime() from localtime()-generated Time::Piece:
Thu Feb 6 16:50:00 2003(epoch: 1044568200)
Thu, 06 Feb 2003 16:50:00 EST
----
This is on Linux 2.4.18, and perl, v5.6.1 built for i386-linux
Now am I missing something here? The GMT values should not be reporting in EST, should they? This seems to be a problem with how is_local is set, correct? The naked gmtime() constructor is handling the hours correctly, but not is_local. gmtime() from a localtime() object is failing utterly.
Bad bug!
Thanks,
Matt