Permalink
Browse files

Merge branch 'ruby-2.2'

* ruby-2.2:
  Check `respond_to` before delegation due to: ruby/ruby@d781caa
  • Loading branch information...
2 parents 35cc328 + 2af5303 commit bd1bf2c5b8480fae0379890347d58b9fe8231e3e @tenderlove tenderlove committed Jan 10, 2014
@@ -151,7 +151,11 @@ def utc_offset
# 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? :to_datetime
+ super other.to_datetime
+ else
+ nil
+ end
end
end
@@ -234,6 +234,7 @@ def formatted_offset(colon=true, alternate_utc_string = nil)
# Compare this time zone to the parameter. The two are compared first on
# their offsets, and then by name.
def <=>(zone)
+ return unless zone.respond_to? :utc_offset
result = (utc_offset <=> zone.utc_offset)
result = (name <=> zone.name) if result == 0
result

0 comments on commit bd1bf2c

Please sign in to comment.