Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- require 'pp'
- class Time
- class << self
- alias_method :_original_load, :_load
- def _load(marshaled_time)
- time = _original_load(marshaled_time)
- # utc = time.send(:remove_instance_variable, '@marshal_with_utc_coercion')
- time
- # utc ? time.utc : time
- end
- end
- alias_method :_original_dump, :_dump
- def _dump(*args)
- obj = self.frozen? ? self.dup : self
- obj.instance_variable_set('@marshal_with_utc_coercion', utc?)
- obj._original_dump(*args)
- end
- end
- t = Time.local(2000).freeze
- pp t
- m = Marshal.dump t
- pp t
- t2 = Marshal.load(m)
- pp t2
Add Comment
Please, Sign In to add comment