perl DateTime now() problem
- by Sergey Sinkovskiy
Having this script
use DateTime;
use DateTime::Format::Strptime;
my $p = DateTime::Format::Strptime->new(pattern => '%F %T',
time_zone => 'local');
my $dt1 = DateTime->now(time_zone=>'local')->set_time_zone('UTC');
my $dt2 = $p->parse_datetime('2010-10-23 14:10:02')->set_time_zone('UTC');
print Dumper($dt1->hms);
print Dumper($dt2->hms);
print Dumper($dt1 > $dt2);
The problem is that $dt1 is off by 1 hour. Like
$VAR1 = '12:09:55';
$VAR1 = '11:10:02';
$VAR1 = 1;
If I remove set_time_zone('UTC') in both cases - dumped values are okay.
My feel is that somewhere DST is taken into account unnecessarily, but can't find out.
Update: I dumped $dt-time_zone-name and $dt-offset for both and that's what i get.
$VAR1 = 'Europe/Kiev';
$VAR1 = 7200;
$VAR1 = 'Europe/Kiev';
$VAR1 = 10800;
How this could be possible?