Sha256: 7a4215d37c9b853ea19590b90973da680809fe32518468e342c081c8809a796a

Contents?: true

Size: 920 Bytes

Versions: 132

Compression:

Stored size: 920 Bytes

Contents

# Ruby 1.9.2 adds utc_offset and zone to Time, but marshaling only
# preserves utc_offset. Preserve zone also, even though it may not
# work in some edge cases.
if Time.local(2010).zone != Marshal.load(Marshal.dump(Time.local(2010))).zone
  class Time
    class << self
      alias_method :_load_without_zone, :_load
      def _load(marshaled_time)
        time = _load_without_zone(marshaled_time)
        time.instance_eval do
          if zone = defined?(@_zone) && remove_instance_variable('@_zone')
            ary = to_a
            ary[0] += subsec if ary[0] == sec
            ary[-1] = zone
            utc? ? Time.utc(*ary) : Time.local(*ary)
          else
            self
          end
        end
      end
    end

    alias_method :_dump_without_zone, :_dump
    def _dump(*args)
      obj = dup
      obj.instance_variable_set('@_zone', zone)
      obj.send :_dump_without_zone, *args
    end
  end
end

Version data entries

132 entries across 127 versions & 13 rubygems

Version Path
activesupport-4.2.11.3 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.11.2 lib/active_support/core_ext/time/marshal.rb
cocoapods-dependency-html-0.0.2 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/core_ext/time/marshal.rb
cocoapods-dependency-html-0.0.1 vendor/bundle/gems/activesupport-4.2.11.1/lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.11.1 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.11 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.10 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.10.rc1 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.9 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.9.rc2 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.9.rc1 lib/active_support/core_ext/time/marshal.rb
enju_leaf-1.2.1 vendor/bundle/ruby/2.3/gems/activesupport-4.2.8/lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.8 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.8.rc1 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.7.1 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.7 lib/active_support/core_ext/time/marshal.rb
activesupport-4.1.16 lib/active_support/core_ext/time/marshal.rb
activesupport-4.1.16.rc1 lib/active_support/core_ext/time/marshal.rb
activesupport-4.2.7.rc1 lib/active_support/core_ext/time/marshal.rb
ish_lib_manager-0.0.1 test/dummy/vendor/bundle/ruby/2.3.0/gems/activesupport-4.2.6/lib/active_support/core_ext/time/marshal.rb