Well, I have face a little issue with DateTime, find the number of day between 2 dates. So my first approch was :
my $d1 = DateTime->now();
my $d2 = DateTime->now()->add(days => 500);
#so d2 - d1 should be 500 days
my $duration = $d2 - $d1;
say $duration->in_units('days');
#11
#what is this ???
In fact a substract of 2 DateTime is express in month and days. So they is no way to get only from this information the number of days.
So $duration->delta_days = 11 and $duration->delta_month() = 16
How to get back my 500 days ?
Like this :
my $d1 = DateTime->now();
my $d2 = DateTime->now()->add(days => 500);
my $duration = $d1->delta_days($d2);
say $duration->in_units('days');
#500
Now it's good ! But in this case you don't have the number of month, you can use the above method which use $d1->delta_md($d2) by default.