in reply to Re^2: [ DateTime::Duration ] off by one problem with negative seconds
in thread [ DateTime::Duration ] off by one problem with negative seconds

> I suppose it's because there is an inner test for falseness to see if the nanosecs are 0 ... but "000000000" OTOH is true.

found the problem in the constructor

if ( $p{nanoseconds} ) { # <-- +0 sho +uld fix it $self->{nanoseconds} = $p{nanoseconds}; $self->_normalize_nanoseconds; } else { # shortcut - if they don't need nanoseconds $self->{nanoseconds} = 0; } ... # and later # make the signs of seconds, nanos the same; 0 < abs(nanos) < MAX_NANO +S # NB this requires nanoseconds != 0 (callers check this already) # <- +- GOTCHA! sub _normalize_nanoseconds { ...

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery FootballPerl is like chess, only without the dice

  • Comment on Re^3: [ DateTime::Duration ] off by one problem with negative seconds
  • Download Code