On Tue, 25 Jan 2005, Hill, Ronald wrote:

However, after checking the docs for this function. I found this:

The C<delta_md> and C<delta_days> methods truncate the duration so
that any fractional portion of a day is ignored.  The C<delta_ms>
method converts any day and month differences to minutes.

Unlike the subtraction methods, B<these methods always return a
positive (or zero) duration>.
^^^^^^^^^^^^^^^^^^^^^^^^^^^
but if I do thisuse strict;
use warnings;
use DateTime;
use DateTime::Format::MySql;


my $start_date = DateTime::Format::MySQL->parse_date( '2005-01-05' ); my $end_date = DateTime::Format::MySQL->parse_date( '2005-01-23' );

my $dur = $start_date->delta_days( $end_date );

if ($dur->is_positive) {print "it's positive\n"}
if ($dur->is_negative) {print "it's negative\n"}
print $dur->delta_days;

I get this:
F:\scripts>my.pl
it's negative
-18

Which is correct but does not match what the docs say.
Anyway I hope this helps.

Yeah, I noticed this too. It's a bug (the docs are right) and will be fixed in the next release.



-dave

/*===================================================
VegGuide.Org                        www.BookIRead.com
Your guide to all that's veg.       My book blog
===================================================*/

Reply via email to