Days between two dates
Delfim Machado
dbcm at profundos.org
Thu Dec 22 15:25:46 GMT 2005
Hi,
you can use Date::Calc qw(Date_to_Days).
On Dec 22, 2005, at 15:10, Paul Makepeace wrote:
> A should-be-obvious question. How does one find the number of days
> between two dates, without converting to epoch? (so I can do while
> --$days >= 0) I thought ($end_dt - $start_dt)->in_units('days')
> would do
> it but if the ::Duration ends up with a 'month' figure data is
> effectively
> lost (which month? i.e. how long?) and then you can't convert to days.
>
> Here's an example where there's a definite answer but DateTime loses
> info by having its ::Duration use months:
>
> $ perl -MDateTime -le '
> $s=DateTime->new(year => 2005, month => 10, day => 1);
> $d=DateTime->new(year => 2005, month => 12, day => 1);
> print(($d-$s)->in_units("days"))'
> 0
> $
>
> Paul
>
>
> --
> Paul Makepeace .............................. http://paulm.com/
> inchoate/
>
> "What is the word for octopus in polari? Swim and talk."
> -- http://paulm.com/toys/surrealism/
--
Del Mac
More information about the london.pm
mailing list