On Mon, Jun 30, 2003 at 12:20:43PM -0500, Dave Rolsky wrote:
> >  2) Having a way to construct this directly would be nice being able
> >     to make a duration that you can not directly construct seems odd.
> 
> Well, maybe.  Right now the constructor is really simple, which is good.
> More functionality is nice, but so is simplicity.

Ok, playing with this a bit more (using DateTime 0.13) makes me confused:

--
my $d = DateTime::Duration->new(hours => -3, minutes => 57, seconds => 2);
--
Gives 'minutes' => -123, 'seconds' => -2.

--
my $d = DateTime::Duration->new(hours => 3, minutes => -57, seconds => 2);
--
Gives 'minutes' => -123, 'seconds' => -2.

BUT

--
my $d = DateTime::Duration->new(hours => -3, minutes => -57, seconds => 2);
--
Gives 'minutes' => -237, 'seconds' => -2.

AND

--
my $d = DateTime::Duration->new(hours => 3, minutes => 57, seconds => -2);
--
Gives 'minutes' => -237, 'seconds' => -2.

I am totally mystified.  I read "If any of the numbers are negative,
the entire duration is negative." as indicating that the individual
signs don't matter.

I think the error is on DT::Duration line 52:
  $self->{minutes} = abs( ( $p{hours} * 60 ) + $p{minutes}  ) * $self->{sign}; 
Which should perhaps be:
  $self->{minutes} = ( abs( $p{hours} * 60 ) + abs( $p{minutes} ) ) * $self->{sign}; 

                -ben

Reply via email to