Subject: | subtract_datetime_absolute issue |
Date: | Sat, 9 Apr 2016 15:44:14 -0700 |
To: | bug-DateTime [...] rt.cpan.org |
From: | Earl Oliver <earl.oliver [...] gmail.com> |
DateTime-> subtract_datetime_absolute does not yield correct differences between two DateTime objects.
I am using DateTime as packaged with: Perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level
The following sample code demonstrates the issue consistently:
#!/usr/bin/perl
use DateTime;
my $result_date =
DateTime->new(
year => 2016,
month => 04,
day => 9,
hour => 19,
minute => 35,
second => 24);
my $dtx = DateTime->from_epoch(epoch => 1460229600);
print "result_date epoch = ".$result_date->epoch()."\n";
print "dtx epoch = ".$dtx->epoch()."\n";
print "epoch diff: ".($result_date->epoch() - $dtx->epoch())."\n"; # 924, correct
my $seconds = $result_date->subtract_datetime_absolute($dtx)->seconds;
print 'subtract_datetime_absolute diff: '.$seconds."\n"; # 899, incorrect, off by 25 seconds.
Message body not shown because it is not plain text.