-
-
Notifications
You must be signed in to change notification settings - Fork 942
Closed
Milestone
Description
The DateTime comparison operator in JRuby 1.7.5 and later considers two DateTime instances that differ by less than a millisecond (and by more than 0s) to be equivalent. For example (using JRuby 1.7.9 in 1.9 mode):
> d1 = DateTime.new(2013, 12, 6, 0, 0, Rational(1, 10000))
=> #<DateTime: 2013-12-06T00:00:00+00:00 ((2456633j,0s,100000n),+0s,2299161j)>
> d1.day_fraction
=> (1/864000000)
> d2 = DateTime.new(2013, 12, 6, 0, 0, Rational(2, 10000))
=> #<DateTime: 2013-12-06T00:00:00+00:00 ((2456633j,0s,200000n),+0s,2299161j)>
> d2.day_fraction
=> (1/432000000)
> d1 <=> d2
=> 0d1 is 0.0001s earlier than d2, so d1 <=> d2 should have returned -1 instead of 0.
JRuby 1.7.4, MRI 1.9.3 and MRI 2.0.0 return the correct result.
It looks like the problem is that <=> only compares @dt, but not @sub_millis.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels