Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.Sign up
Difference of DateTimes with fractional milliseconds calculated incorrectly #5493
The following appears to be a regression in DateTime handling in JRuby 9.2:
It appears that the DateTime subtraction code in JRuby 9.2 is incorrectly interpreting fractional milliseconds as fractional days. Thus, instead of the expected difference of 59.000001 seconds, the code is instead returning a difference of 59 + (60 * 60 * 24 * 0.001) = 59 + 86.4 = 145.4 seconds (plus some irrelevant floating point roundoff noise).
Ps. We've had issues with DateTime math in JRuby 9.2 before, and pull request #5369 by @massive was intended to address them. However, while commit 1360a4a appears to have made the specs included in that PR pass, it does not seem to have fully fixed the underlying problem(s), as the examples above demonstrate. Until this issue is properly fixed (or we find a reliable work-around), this is blocking JRuby 9.2 adoption for us.
Indeed, looking at the code in https://github.com/jruby/jruby/blob/22.214.171.124/core/src/main/java/org/jruby/ext/date/RubyDate.java#L1210, I'm pretty sure this bug occurs because