-
-
Notifications
You must be signed in to change notification settings - Fork 942
Description
The following appears to be a regression in DateTime handling in JRuby 9.2:
[1] pry(main)> JRUBY_VERSION
"1.7.27"
[2] pry(main)> (DateTime.new(2018, 1, 1, 0, 1, 29.000001) - DateTime.new(2018, 1, 1, 0, 0, 30)).to_f * 24 * 60 * 60
59.000001
[1] pry(main)> JRUBY_VERSION
"9.1.15.0"
[2] pry(main)> (DateTime.new(2018, 1, 1, 0, 1, 29.000001) - DateTime.new(2018, 1, 1, 0, 0, 30)).to_f * 24 * 60 * 60
59.000001
[1] pry(main)> JRUBY_VERSION
"9.2.4.1"
[2] pry(main)> (DateTime.new(2018, 1, 1, 0, 1, 29.000001) - DateTime.new(2018, 1, 1, 0, 0, 30)).to_f * 24 * 60 * 60
145.40000008881543
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.