in reply to DateTime::Span intersection inconsistencies

If anyone’s going to open a bug-ticket on this one, I would like to see it provided with a “fuzz factor.”   This would serve to eliminate the “one nanosecond problem,” among other things.

What this logic would do, is to add the “fuzz factor” to the upper-end or the lower-end (as the case may be) of two intervals that are going to be compared, only of course for the purposes of comparison.   (If you set a fuzz-interval of two seconds, for example, then an interval ending at "09:59" would be treated as though it ended at "10:01" for the purpose of comparison with an interval that starts at "10:00" and is therefore treated as though it started at "09:59.")   Even though computer clocks in a network are routinely synchronized to one another, they can still be off by a couple of jiffies.   A numerical “less-than” comparison is sometimes too ruthlessly precise.   Whether the fuzz-factor is set large or small, this improvement would make the module considerably more useful.

Replies are listed 'Best First'.
Re^2: DateTime::Span intersection inconsistencies
by ikegami (Patriarch) on Jul 02, 2011 at 02:40 UTC

    This would serve to eliminate the “one nanosecond problem,” among other things.

    Adding a fuzz factor would not fix passing the wrong arguments to the constructor (as was the case here), it would just hide the error.

    As for doing a fuzzy comparison, it's already quite easy.

Re^2: DateTime::Span intersection inconsistencies
by mikeman (Acolyte) on Jul 03, 2011 at 16:57 UTC

    I certainly won't be opening a bug ticket, as the problem was not due to a bug. I started with some reasonably complex code which produced results that I was not expecting. I then boiled that code down to a much smaller test script, and along the way I failed to correctly read and understand the associated documentation.

    It was only after posting the question that I realised my mistake - at that point the reason for the seemingly inconsistent results became clear, and the results made perfect sense.