Skip to content
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 · Fixed by #4522
Closed

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

BanzaiMan opened this issue Jul 2, 2013 · 5 comments · Fixed by #4522

Comments

@BanzaiMan
Copy link
Member

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
Copy link
Contributor

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
Copy link
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
Copy link
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
Copy link
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
Copy link
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
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 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
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants