# File activesupport/lib/active_support/core_ext/time/calculations.rb, line 317
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)
# also avoid ActiveSupport::TimeWithZone#to_time before Rails 8.0
if other.respond_to?(:comparable_time)
compare_without_coercion(other.comparable_time)
else
compare_without_coercion(other.to_time)
end
else
to_datetime <=> other
end
end