Many thanks a +0 to explicitly convert to number is fixing the issue.

> If I were to supply a value for nano- or microsecond, I would have thought that an integer would have been sufficient, and not to have supply a string for the value.

The string is an artefact from an sprintf to convert non-nanos to nanos.

> All of the numbers must be integers.

It's Perl's dogma to treat all convertible scalars alike, including integers and strings of integers.

DB<75> use warnings; print "001"+"001" # no warnings 2 DB<76>

I read the docs as "don't pass real numbers".

Keep in mind that the nanosecs could have been read from a file and come as string inside a variable.

DT::D only fails in this special case and I suppose it's because there is an inner test for falseness to see if the nanosecs are 0 ... but "000000000" OTOH is true.

some minutes later

My Boolean theory seems to be right, passing "0" works fine (false), but "00" fails (true).

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


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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.