Greetings,
I've got a problem. It's probably a misunderstanding on my part.
Here's a script:
---
#!/usr/bin/perl -w
use strict;
use warnings;
use DateTime;
my $dt1 =
DateTime->new(year => 2004,
month => 10,
day => 31,
hour => 1,
minute => 3,
second => 9,
time_zone => 'America/Edmonton');
print $dt1->datetime(), ' => ', $dt1->epoch(), "\n";
my $dt2 =
DateTime->from_epoch(epoch => 1099206189, time_zone => 'America/Edmonton');
print $dt2->datetime(), ' => ', $dt2->epoch(), "\n";
---
And here's the output:
---
2004-10-31T01:03:09 => 1099209789
2004-10-31T01:03:09 => 1099206189
---
This is a problem because I have dates that are sometimes specified as
human-readable strings and sometimes as seconds-from-the-epoch. I
convert the former to the latter and then go to work, but for my
purposes I need the same date to map to the same epoch. The whole
point of what I'm doing is to match the dates in human-readable string
to the dates as seconds-from-the-epoch.
What am I doing wrong?
Mark