1
0
Fork 0
mirror of https://github.com/rails/rails.git synced 2022-11-09 12:12:34 -05:00

Remove unneeded Time patch to support Ruby 1.9

This commit is contained in:
Rafael Mendonça França 2015-01-04 15:37:19 -03:00
parent 21f02f3485
commit 479bd52af8
2 changed files with 2 additions and 30 deletions

View file

@ -1,5 +1,4 @@
require 'active_support/core_ext/time/acts_like'
require 'active_support/core_ext/time/calculations'
require 'active_support/core_ext/time/conversions'
require 'active_support/core_ext/time/marshal'
require 'active_support/core_ext/time/zones'

View file

@ -1,30 +1,3 @@
# 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
require 'active_support/deprecation'
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
ActiveSupport::Deprecation.warn("This is deprecated and will be removed in Rails 5.1 with no replacement.")