develooper Front page | perl.datetime | Postings from May 2003

Re: [cpan #2601] Bug in epoch() method

Thread Previous | Thread Next
From:
Rick Measham
Date:
May 19, 2003 00:23
Subject:
Re: [cpan #2601] Bug in epoch() method
Message ID:
BAEEC382.B22%rickm@iSite.net.au
> Return value from epoch() method is incorrect for many+varied years due to
> Time::Local's year parsing. Try converting the MacOS epoch from a DateTime
> object to an epoch time and back again, for example.

Maybe I don't quite get this. Here's my test code:

use DateTime;
print "Mac Epoch: " . time() . "\n";

$dt=DateTime->now();
print "DT Epoch:" . $dt->epoch() . "\n";

$dt2 = DateTime->from_epoch(epoch => $dt->epoch());
print "D2T Epoch:" . $dt2->epoch() . "\n";

Which prints:
Mac Epoch: 3136209605
DT Epoch:3136209605
D2T Epoch:3136209605

As would be expected. Have I missed the point here? Even if I
$dt->set(year=>1974) I get the right responses.

Anyone?

I wish he'd at least left his email address :)

Cheers!
Rick


Thread Previous | Thread Next


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