Skip to content

Incorrect values resulting from to_date on a Time object #5279

@WToa

Description

@WToa

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)>" 

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions