Module: DateAndTime::Compatibility

Included in:
ActiveSupport::TimeWithZone, DateTime, Time
Defined in:
lib/active_support/core_ext/date_and_time/compatibility.rb

Class Method Summary collapse

Class Method Details

.included(base) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/active_support/core_ext/date_and_time/compatibility.rb', line 15

def self.included(base)
  base.class_eval do
    remove_possible_method :to_time

    def to_time
      if preserve_timezone
        @_to_time_with_instance_offset ||= getlocal(utc_offset)
      else
        @_to_time_with_system_offset ||= getlocal
      end
    end
  end
end