-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Allow DateTime comparison to Infinity/-Infinity. #3457
Conversation
-1 |
damn it mike |
@@ -127,6 +127,10 @@ class DateTime | |||
|
|||
# Layers additional behavior on DateTime#<=> so that Time and ActiveSupport::TimeWithZone instances can be compared with a DateTime | |||
def <=>(other) | |||
super other.to_datetime | |||
if other.respond_to?(:infinite?) and other.infinite? != 0 | |||
-other.infinite? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if self is also an infinite you should check for equality and relative signage with other
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
DateTime can't be an infinite, I believe. So self
could never be an infinite.
maybe mike meant -∞ :). I added a comment and test cases to your pull request to cover equality and signage comparisons if both operands are a flavor of infinite. |
Thanks! I'll make those changes soon. |
I added the missing test cases. |
Is this still an issue? |
Yes. |
cc @tenderlove |
This will need a big rebase if it's ever to be included. |
@joevandyk ping! any interest in keeping this current? |
this isn't in there yet? :) i'll look at it. |
Fixed by #7350 |
A continuation of the fixes in #544 -- @tenderlove let ActiveRecord support Infinite timestamps, but you can't compare them to other DateTime values. This commit fixes that.