Skip to content

Instantly share code, notes, and snippets.

@NZKoz
Created September 4, 2008 12:49
Show Gist options
  • Save NZKoz/8766 to your computer and use it in GitHub Desktop.
Save NZKoz/8766 to your computer and use it in GitHub Desktop.
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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment