Closed
Description
When a pre-Unix epoch time is converted to the timestamp, JRuby rounds the value up rather than down.
MRI:
speed% ruby -v ruby 2.7.0p0 (2019-12-25 revision 647ee6f091) [x86_64-linux] speed% irb irb(main):001:0> time = Time.utc(1960, 1, 1, 0, 0, 0, 999_999) irb(main):002:0> time.to_f => -315619199.000001 irb(main):003:0> time.to_i => -315619200
JRuby:
speed% ruby -v jruby 9.2.11.0 (2.5.7) 2020-03-02 612d7a05a6 OpenJDK 64-Bit Server VM 25.171-b11 on 1.8.0_171-8u171-b11-2-b11 +jit [linux-x86_64] speed% irb irb(main):001:0> time = Time.utc(1960, 1, 1, 0, 0, 0, 999_999) => 1960-01-01 00:00:00 UTC irb(main):002:0> time.to_f => -315619199.000001 irb(main):003:0> time.to_i => -315619199
The times should be rounded down so that comparisons like foo <= upper_bound
, when upper_bound has a fractional second, continue to exclude the following second.
Metadata
Metadata
Assignees
Labels
No labels