New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
BanzaiMan opened this Issue Jul 2, 2013 · 5 comments

Comments

Projects
None yet
4 participants
@BanzaiMan
Member

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=Time.utc(2013,6,30,14,56,14,263031.604)
t2=Time.utc(2013,6,30,14,56,14,263031.605)
t1 == t2 # should be false
@petervandenabeele

This comment has been minimized.

Contributor

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

This comment has been minimized.

Member

kares commented Jan 17, 2017

still a valid issue (t1 == t2 holds in 9.1.7.0)

@kares kares added this to the JRuby 9.1.8.0 milestone Jan 17, 2017

@headius

This comment has been minimized.

Member

headius commented Mar 3, 2017

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

@headius headius removed this from the JRuby 9.1.8.0 milestone Mar 3, 2017

@headius

This comment has been minimized.

Member

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

This comment has been minimized.

Member

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 added a commit to kares/jruby that referenced this issue Mar 5, 2017

fix: Time creation (utc/local) usec 'double' rounding to be intuitive
resolves jruby#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 kares closed this in #4522 Mar 13, 2017

@kares kares added this to the JRuby 9.1.9.0 milestone Mar 13, 2017

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