Re: Duration or elapsed time in days?

2010-09-02 Thread Gabor Szabo
On Thu, Sep 2, 2010 at 7:01 PM, Dave Rolsky  wrote:
> On Thu, 2 Sep 2010, Gabor Szabo wrote:
>
>> $d1 = DateTime->new(...);
>> $d2 = DateTime->new(...);
>>
>> my $sec = $d2->subtract_datetime_absolute($d1)->seconds;
>> print $sec/60/60/24, "\n";
>
>  my $dur = $d1->delta_days($d2);
>  print $dur->in_units('days');

thanks
  Gabor


Re: Duration or elapsed time in days?

2010-09-02 Thread Dave Rolsky

On Thu, 2 Sep 2010, Gabor Szabo wrote:


$d1 = DateTime->new(...);
$d2 = DateTime->new(...);

my $sec = $d2->subtract_datetime_absolute($d1)->seconds;
print $sec/60/60/24, "\n";


  my $dur = $d1->delta_days($d2);
  print $dur->in_units('days');


-dave

/*
http://VegGuide.org   http://blog.urth.org
Your guide to all that's veg  House Absolute(ly Pointless)
*/


Duration or elapsed time in days?

2010-09-02 Thread Gabor Szabo
Hi,

I am probably missing something obvious but I could not yet figure out how can I
get the "number of days" between two DateTime objects.
So far the best I managed was

$d1 = DateTime->new(...);
$d2 = DateTime->new(...);

my $sec = $d2->subtract_datetime_absolute($d1)->seconds;
print $sec/60/60/24, "\n";

Is there a nicer way that does not require me to remember
how many minutes are in an hour?

Gabor