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

[ji] make java.util.Date duck type some of Ruby's Time #3801

Closed
kares opened this issue Apr 13, 2016 · 2 comments
Closed

[ji] make java.util.Date duck type some of Ruby's Time #3801

kares opened this issue Apr 13, 2016 · 2 comments

Comments

@kares
Copy link
Member

kares commented Apr 13, 2016

that would probably help some user confusion: #2049

currently Time auto-coerces to java.util.Date (e.g. with Java collections) and it stays that way :

require 'active_support/all'
1.second # 1 second
Time.now.beginning_of_day # works

list = java.util.ArrayList.new
list.add(1)
list.add(Time.now)

list.get(0).second # 1 second
list.get(1).beginning_of_day # undefined method `beginning_of_day' for #<Java::JavaUtil::Date:0x409986fe>
@kares
Copy link
Member Author

kares commented Apr 14, 2016

OK, due how java.util.Date handles months this probably won't be done (to play safe):

  • Java's date.getMonth returns 0-11
  • date.getMonth is aliased as date.month (0-11)
  • Ruby's Time#month returns 1..12 so this would collide ;(

@kares
Copy link
Member Author

kares commented Aug 30, 2016

won't fix since it would get confusing to return a different month based on Java/Ruby calls.
probably a solution - in the long term - would be moving to Java 8's new date/times APIs ...

@kares kares closed this as completed Aug 30, 2016
@kares kares added this to the Won't Fix milestone Aug 30, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant