Subject: | DateTime::Duration reports incorrect weeks |
According to the docs, the following code should return 105 (or maybe 104 but that's why I need the code to work :) weeks but it in fact returns 4, which I think is the difference after subtracting months but it's suppoed to be just the number of weeks in total. Months seems about right but Days is also wrong, representing the number of days in the weeks that it thinks it has.
Simon.
simonw@kryten:~/perl/svg$ cat dtbug.pl
#! /usr/bin/perl
use DateTime;
my $start = DateTime->new( year => 2002,
month => 9,
day => 3 );
my $end = DateTime->new( year => 2004,
month => 8,
day => 31 );
my $diff = $end - $start;
print "First : ".$start->dmy."\n";
print "Latest : ".$end->dmy."\n";
print "Diff : ".$diff->in_units( 'months' )." months\n";
print "Diff : ".$diff->in_units( 'weeks' )." weeks\n";
print "Diff : ".$diff->in_units( 'days' )." days\n";
simonw@kryten:~/perl/svg$ perl dtbug.pl
First : 03-09-2002
Latest : 31-08-2004
Diff : 23 months
Diff : 4 weeks
Diff : 28 days
simonw@kryten:~/perl/svg$