Sha256: 99bb5d9a03d86f91ac39f621384bc2532f8f75a78aa7aa39dd31af7929387d4a

Contents?: true

Size: 778 Bytes

Versions: 28

Compression:

Stored size: 778 Bytes

Contents

require 'active_support/core_ext/module/attribute_accessors'

module DateAndTime
  module Compatibility
    # 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.
    mattr_accessor(:preserve_timezone, instance_writer: false) { false }

    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

Version data entries

28 entries across 27 versions & 6 rubygems

Version Path
tdiary-5.0.5 vendor/bundle/gems/tdiary-5.0.4/vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
tdiary-5.0.5 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.2.1 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.2.0 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.9 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.8 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.7 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.6 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.4 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
tdiary-5.0.4 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.3 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.2 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.1 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
lazy_record-0.1.0 vendor/bundle/gems/activesupport-5.0.2/lib/active_support/core_ext/date_and_time/compatibility.rb
activesupport-5.0.2 lib/active_support/core_ext/date_and_time/compatibility.rb
activesupport-5.0.2.rc1 lib/active_support/core_ext/date_and_time/compatibility.rb
autocompl-0.2.2 test/dummy/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1/lib/active_support/core_ext/date_and_time/compatibility.rb
autocompl-0.2.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1/lib/active_support/core_ext/date_and_time/compatibility.rb
autocompl-0.2.0 test/dummy/vendor/bundle/ruby/2.3.0/gems/activesupport-5.0.1/lib/active_support/core_ext/date_and_time/compatibility.rb