Time#nsec rounding is happening at a place we don't want. #843

BanzaiMan opened this Issue Jul 2, 2013 · 5 comments


None yet
4 participants

BanzaiMan commented Jul 2, 2013

As reported in http://markmail.org/search/?q=jruby-user#query:jruby-user%20order%3Adate-backward+page:1+mid:3kk6wvustmpzyd2n+state:results

t1 == t2 # should be false

petervandenabeele commented Jul 6, 2013

These 2 work-arounds in petervandenabeele/dbd@f560c6b allowed me to pass my tests:

  • use a 2 ns minimum distance between consecutive facts
  • also add 0.3 nanosecond offset to fix downward rounding

kares commented Jan 17, 2017

still a valid issue (t1 == t2 holds in

kares added this to the JRuby milestone Jan 17, 2017


headius commented Mar 3, 2017

@kares Are you planning to work on this since you tagged it for

headius removed this from the JRuby milestone Mar 3, 2017


headius commented Mar 3, 2017

I'm clearing the target on this one since it has been an outstanding issue for a long time. We welcome someone picking this up and trying to fix it.


kares commented Mar 5, 2017

@headius will take a stub at this old timer. wanted to get a few ones in, which you already looked into. thx

@kares kares added a commit to kares/jruby that referenced this issue Mar 5, 2017

@kares kares fix: Time creation (utc/local) usec 'double' rounding to be intuitive
resolves #843

its still not the same as MRI (2.3.3) but it seems more correct e.g.

2.3.3 :006 > Time.utc(2013,6,30,14,56,14,263031.604).nsec
 => 263031603 
2.3.3 :007 > Time.utc(2013,6,30,14,56,14,263031.605).nsec
 => 263031604 

... while JRuby (after this change) :

irb(main):001:0> Time.utc(2013,6,30,14,56,14,263031.604).nsec
=> 263031604
irb(main):002:0> Time.utc(2013,6,30,14,56,14,263031.605).nsec
=> 263031605

irb(main):003:0> Time.utc(2013,6,30,14,56,14,263031.6053).nsec
=> 263031605
irb(main):004:0> Time.utc(2013,6,30,14,56,14,263031.6056).nsec
=> 263031606

kares closed this in #4522 Mar 13, 2017

kares added this to the JRuby milestone Mar 13, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment