Guest User

Untitled

a guest
Feb 19th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. require 'pp'
  2. class Time
  3. class << self
  4. alias_method :_original_load, :_load
  5. def _load(marshaled_time)
  6. time = _original_load(marshaled_time)
  7. # utc = time.send(:remove_instance_variable, '@marshal_with_utc_coercion')
  8. time
  9. # utc ? time.utc : time
  10. end
  11. end
  12.  
  13. alias_method :_original_dump, :_dump
  14. def _dump(*args)
  15. obj = self.frozen? ? self.dup : self
  16. obj.instance_variable_set('@marshal_with_utc_coercion', utc?)
  17. obj._original_dump(*args)
  18. end
  19. end
  20.  
  21. t = Time.local(2000).freeze
  22. pp t
  23. m = Marshal.dump t
  24. pp t
  25. t2 = Marshal.load(m)
  26. pp t2
Add Comment
Please, Sign In to add comment