Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re^3: [ DateTime::Duration ] off by one problem with negative seconds

by LanX (Saint)
on Dec 28, 2019 at 03:58 UTC ( [id://11110685]=note: print w/replies, xml ) Need Help??


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

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11110685]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others cooling their heels in the Monastery: (5)
As of 2024-03-28 14:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found