Created
January 10, 2014 20:27
-
-
Save eregon/969d6d7afbf069d8b4d1 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
diff --git a/activesupport/lib/active_support/core_ext/date_time/calculations.rb b/activesupport/lib/active_support/core_ext/date_time/calculations.rb | |
index 8e5d723..487f8d9 100644 | |
--- a/activesupport/lib/active_support/core_ext/date_time/calculations.rb | |
+++ b/activesupport/lib/active_support/core_ext/date_time/calculations.rb | |
@@ -151,7 +151,7 @@ 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 | |
+ super other.to_datetime if other.respond_to? :to_datetime | |
end | |
end | |
diff --git a/activesupport/lib/active_support/time_with_zone.rb b/activesupport/lib/active_support/time_with_zone.rb | |
index 50db7da..b799ca0 100644 | |
--- a/activesupport/lib/active_support/time_with_zone.rb | |
+++ b/activesupport/lib/active_support/time_with_zone.rb | |
@@ -69,8 +69,9 @@ module ActiveSupport | |
# Returns the simultaneous time in <tt>Time.zone</tt>, or the specified zone. | |
def in_time_zone(new_zone = ::Time.zone) | |
- return self if time_zone == new_zone | |
- utc.in_time_zone(new_zone) | |
+ new_time_zone = ::Time.find_zone! new_zone | |
+ return self if time_zone == new_time_zone | |
+ utc.in_time_zone(new_time_zone) | |
end | |
# Returns a <tt>Time.local()</tt> instance of the simultaneous time in your |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment