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
In reply to Re^3: [ DateTime::Duration ] off by one problem with negative seconds
by LanX
in thread [ DateTime::Duration ] off by one problem with negative seconds
by LanX
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |