Module: DateAndTime::Compatibility
Relationships & Source Files | |
Extension / Inclusion / Inheritance Descendants | |
Included In:
| |
Defined in: | activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb |
Class Attribute Summary
-
.preserve_timezone
(also: #preserve_timezone)
rw
If true,
to_time
preserves the timezone offset of receiver. -
.utc_to_local_returns_utc_offset_times
(also: #utc_to_local_returns_utc_offset_times)
rw
Change the output of
ActiveSupport::TimeZone.utc_to_local
.
Instance Attribute Summary
- #preserve_timezone readonly
- #utc_to_local_returns_utc_offset_times readonly
Class Attribute Details
.preserve_timezone (rw) Also known as: #preserve_timezone
If true, to_time
preserves the timezone offset of receiver.
NOTE: With Ruby 2.4+ the default for to_time
changed from converting to the local system time, to preserving the offset of the receiver. For backwards compatibility we’re overriding this behavior, but new apps will have an initializer that sets this to true, because the new behavior is preferred.
# File 'activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb', line 14
mattr_accessor :preserve_timezone, instance_writer: false, default: false
.utc_to_local_returns_utc_offset_times (rw) Also known as: #utc_to_local_returns_utc_offset_times
Change the output of ActiveSupport::TimeZone.utc_to_local
.
When true
, it returns local times with an UTC offset, with false
local times are returned as UTC.
# Given this zone:
zone = ActiveSupport::TimeZone["Eastern Time (US & Canada)"]
# With `utc_to_local_returns_utc_offset_times = false`, local time is converted to UTC:
zone.utc_to_local(Time.utc(2000, 1)) # => 1999-12-31 19:00:00 UTC
# With `utc_to_local_returns_utc_offset_times = true`, local time is returned with UTC offset:
zone.utc_to_local(Time.utc(2000, 1)) # => 1999-12-31 19:00:00 -0500
# File 'activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb', line 29
mattr_accessor :utc_to_local_returns_utc_offset_times, instance_writer: false, default: false
Instance Attribute Details
#preserve_timezone (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb', line 14
mattr_accessor :preserve_timezone, instance_writer: false, default: false
#utc_to_local_returns_utc_offset_times (readonly)
[ GitHub ]# File 'activesupport/lib/active_support/core_ext/date_and_time/compatibility.rb', line 29
mattr_accessor :utc_to_local_returns_utc_offset_times, instance_writer: false, default: false