On Mon, 13 Dec 2004, Joshua Hoblitt wrote:

It looks like the normalization is hosed.

This method, for the nth time, does not convert between units which do not have a fixed conversion rate.


I'd also point out that it probably won't work well with non-integer units. I'm not sure what'll happen when you try to add 160.2 minutes to a DateTime object, but it won't be anything good, I'm sure.

use DateTime::Duration;

my $dur = DateTime::Duration->new( hours => 2.67 );

print "hours: ", $dur->in_units( 'hours' ), "\n";

Prints 2, as you'd expect

print "minutes: ", $dur->in_units( 'minutes' ), "\n";

prints 160.2, which is right

print "seconds: ", $dur->in_units( 'seconds' ), "\n";

prints 0

print "nanoseconds: ", $dur->in_units( 'nanoseconds' ), "\n";

also 0

How can that be sane? So you ask for minutes and you get fractional
minutes but you ask for seconds and get zero?

Cause really it should just blow up when you give it fractional anything.


-dave

/*===========================
VegGuide.Org
Your guide to all that's veg.
===========================*/

Reply via email to