On Mon, Dec 15, 2008 at 8:29 PM, Alex Teslik <a...@acatysmoof.com> wrote:
> On Mon, 15 Dec 2008 20:04:26 -0500, Perrin Harkins wrote
>
>> my $d1 = DateTime->today;
>> my $d2 = $d1->clone->subtract(years => 1);
>>
>> my $dur = $d1->delta_days($d2);
>> print $dur->in_units('days') . "\n";
>>
>
> corrected above. I don't know why the days method didn't work.

Thanks Alex.  That does what I want.

Previously I was trying to make this work with overloaded subtraction
instead of delta_days():

my $dur = $d1 - $d2;

The object returned here gives '0' for days() and in_units('days') and
'1' for years().  I think that's by design, but something seems off
here, and my guess is that it's the return of days() on the
delta_days() Duration object (which gives me '2').

- Perrin

Reply via email to