After feedback from another poster, it looks like the answer is the following:
$now->delta_days($dt)->in_units('days');It looks like durations end up broken up into 4 partitions. Conversions can happen only within the partitions, not between:
years/months weeks/days hours/minutes seconds/ns
Also, maybe DateTime should throw some kind of error when you run in_units and a higher partition is being stripped off?
Ex: my $dur = DateTime::Duration->new(months => 3, days=> 4); $dur->in_units(days); # Error; currently 4 $dur->in_units(years); # No error, 0.
Finally, I think some explanation should be added to DT:Duration::in_units that explains all of this!
- Max
Well, here we go again with DateTime::Duration.
Here's a simple problem - How many days are between two DateTime's ? Here is my attempt, but it fails.
Suggestions?
You want the delta_days() method.
