On Thu, 12 Feb 2004, Dave Rolsky wrote:

> > And by what logic should
> >
> >     Duration->new(seconds => 1) - Duration->new(nanoseconds => 500000000)
> >
> > and
> >
> >     Duration->new(nanoseconds => 500000000)
> >
> > differ?
>
> I think you're seeing buggy behavior enshrined via tests ;)
>
> In other words, the code is wrong, and the tests are wrong too.

Or maybe not.  I think I see why Flavio did this.

If we always normalize nanoseconds to be positive, then this gives a
strange result:

  DateTime::Duration->new( nanoseconds => -10 );

We end up a with a duration of -1 seconds, and 999_999_990 nanoseconds.

Perhaps the best of both worlds is to normalize nanoseconds to be positive
_if_ that doesn't make seconds go from positive to negative.


-dave

/*=======================
House Absolute Consulting
www.houseabsolute.com
=======================*/

Reply via email to