提交 bd1bf2c5 编写于 作者: A Aaron Patterson

Merge branch 'ruby-2.2'

* ruby-2.2:
  Check `respond_to` before delegation due to: https://github.com/ruby/ruby/commit/d781caaf313b8649948c107bba277e5ad7307314
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册