class Time
def compare_with_coercion(other)
Layers additional behavior on Time#<=> so that DateTime and ActiveSupport::TimeWithZone instances
def compare_with_coercion(other) # we're avoiding Time#to_datetime and Time#to_time because they're expensive if other.class == Time compare_without_coercion(other) elsif other.is_a?(Time) compare_without_coercion(other.to_time) else to_datetime <=> other end end