aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext/date/operators.rb
blob: decf099624c8f1590a10a013e35a3e254e8ccd03 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
require 'active_support/core_ext/date_and_time/with_duration'

module ActiveSupport
  module DateOperators # :nodoc:
    include DateAndTime::WithDuration

    # Allow Date to be compared with Time by converting to DateTime and relying on the <=> from there.
    def <=>(other)
      if other.is_a?(Time)
        self.to_datetime <=> other
      else
        super
      end
    end
  end
end