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

Incorrect values resulting from to_date on a Time object #5279

Closed
WToa opened this Issue Aug 9, 2018 · 3 comments

Comments

Projects
None yet
3 participants
@WToa
Copy link

commented Aug 9, 2018

We were upgrading our environments to match JRuby 9.2.0.0 and noticed that calling to_date on Time objects lead to different results compared to previous iterations of JRuby and MRI.

Environment

JRuby 9.2.0.0

Expected Behavior

JRuby 9.1.17.0

jruby-9.1.17.0 :006 > Date.today.eql?(Time.now.to_date)
 => true 
jruby-9.1.17.0 :007 > Time.now.to_date.inspect
 => "#<Date: 2018-08-09 ((2458340j,0s,0n),+0s,2299161j)>" 
jruby-9.1.17.0 :008 > Date.today.inspect
 => "#<Date: 2018-08-09 ((2458340j,0s,0n),+0s,2299161j)>" 

Ruby 2.3.3

2.3.3 :005 > Date.today.eql?(Time.now.to_date)
 => true 
2.3.3 :006 > Time.now.to_date.inspect
 => "#<Date: 2018-08-09 ((2458340j,0s,0n),+0s,2299161j)>" 
2.3.3 :007 > Date.today.inspect
 => "#<Date: 2018-08-09 ((2458340j,0s,0n),+0s,2299161j)>" 

Ruby 2.5.1

2.5.1 :004 > Date.today.eql?(Time.now.to_date)
 => true 
2.5.1 :005 > Time.now.to_date.inspect
 => "#<Date: 2018-08-09 ((2458340j,0s,0n),+0s,2299161j)>" 
2.5.1 :006 > Date.today.inspect
 => "#<Date: 2018-08-09 ((2458340j,0s,0n),+0s,2299161j)>" 

Actual Behavior

jruby-9.2.0.0 :002 > Date.today.eql?(Time.now.to_date)
 => false 
jruby-9.2.0.0 :003 > Time.now.to_date.inspect
 => "#<Date: 2018-08-09 ((2458340j,0s,0n),+0s,0j)>" 
jruby-9.2.0.0 :004 > Date.today.inspect
 => "#<Date: 2018-08-09 ((2458340j,0s,0n),+0s,2299161j)>" 
@WToa

This comment has been minimized.

Copy link
Author

commented Aug 9, 2018

Not sure why this is, we looked around in the commits and found:

f30fdfe#diff-c549944ab214525639bedaeffbaac520R61

It seems that the constant ITALY is being replaced by 0 in this.

@dr-itz

This comment has been minimized.

Copy link
Contributor

commented Aug 10, 2018

I run into date related problems on 9.2.0 recently. They were already fixed on master in my case and it looks like this one is ok too:

jruby-head :001 > require 'date'
 => true 
jruby-head :002 > Date.today.eql?(Time.now.to_date)
 => true 
jruby-head :003 > Time.now.to_date.inspect
 => "#<Date: 2018-08-10 ((2458341j,0s,0n),+0s,2299161j)>" 
jruby-head :004 > Date.today.inspect
 => "#<Date: 2018-08-10 ((2458341j,0s,0n),+0s,2299161j)>" 

for reference, it's not exactly the latest, but close enough:

> jruby -v
jruby 9.2.1.0-SNAPSHOT (2.5.0) 2018-07-30 13b2df5 Java HotSpot(TM) 64-Bit Server VM 25.162-b12 on 1.8.0_162-b12 +jit [darwin-x86_64]

So the upcoming 9.2.1 should be ok..

@headius

This comment has been minimized.

Copy link
Member

commented Aug 16, 2018

@dr-itz Thanks for confirming it's fixed on master! We did do some rework of Date in 9.2. and some subsequent fixes in 9.2.1.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.