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

Order of arguments for the == comparison matters for certain Date & TimeWithZone situations #23485

Closed
smtheard opened this issue Feb 4, 2016 · 2 comments

Comments

@smtheard
Copy link

smtheard commented Feb 4, 2016

[13] pry(main)> Date.today - 1 == Date.today - 24.hours
=> false
[14] pry(main)> Date.today - 24.hours == Date.today - 1
=> true
[15] pry(main)> (Date.today - 1) == (Date.today - 24.hours)
=> false
[16] pry(main)> (Date.today - 24.hours) == (Date.today - 1)
=> true

Date#== vs ActiveSupport::TimeWithZone#==

[22] pry(main)> (Date.today - 1).class
=> Date
[23] pry(main)> (Date.today - 24.hours).class
=> ActiveSupport::TimeWithZone

should at the very least return the same result.. likely false.

@meinac
Copy link
Contributor

meinac commented Feb 7, 2016

I can't reproduce this. @smtheard which version of Rails are you using? Also which time zone you are using to configure your application? It would be great if you can share an example application which reproduces this behaviour.

@smtheard
Copy link
Author

smtheard commented Feb 8, 2016

Ah! this was on rails 3.2. I don't have a rails 4 environment at the moment, and didn't think to check it on there. I'll assume that since you can't repo, it is fixed in rails 4.

@smtheard smtheard closed this as completed Feb 8, 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

3 participants