Method: DateAndTime::Compatibility.preserve_timezone

Defined in:
activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb

.preserve_timezoneObject

– This re-implements the behaviour of the mattr_reader, instead of prepending on to it, to avoid overcomplicating a module that is in turn included in several places. This will all go away in Rails 8.0 anyway.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb', line 24

def self.preserve_timezone # :nodoc:
  if @@preserve_timezone.nil?
    # Only warn once, the first time the value is used (which should
    # be the first time #to_time is called).
    ActiveSupport.deprecator.warn(
      "`to_time` will always preserve the receiver timezone rather than system local time in Rails 8.1." \
      "To opt in to the new behavior, set `config.active_support.to_time_preserves_timezone = :zone`."
    )

    @@preserve_timezone = false
  end

  @@preserve_timezone
end