compatibility.rb 565 字节
Newer Older
1
# frozen_string_literal: true
2

3
require_relative "../date_and_time/compatibility"
4
require_relative "../module/redefine_method"
5 6

class DateTime
7 8
  include DateAndTime::Compatibility

9
  silence_redefinition_of_method :to_time
10 11 12 13 14 15 16 17

  # Either return an instance of `Time` with the same UTC offset
  # as +self+ or an instance of `Time` representing the same time
  # in the the local system timezone depending on the setting of
  # on the setting of +ActiveSupport.to_time_preserves_timezone+.
  def to_time
    preserve_timezone ? getlocal(utc_offset) : getlocal
  end
18
end