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

Instance Method Summary collapse

Class Method Details

.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.

[View source]

24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File '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

Instance Method Details

#preserve_timezoneObject

:nodoc:

[View source]

39
40
41
# File 'lib/active_support/core_ext/date_and_time/compatibility.rb', line 39

def preserve_timezone # :nodoc:
  Compatibility.preserve_timezone
end