From: Austin Ziegler Date: 2004-05-14T21:47:37+09:00 Subject: Re: Bug in Marshal? > From: matt [mailto:mhm26@drexel.edu] > Sent: 13 May 2004 20.24 > Subject: Bug in Marshal? > > With the usual deep_copy: > > # Deep copy > class Object > def deep_copy > Marshal.load(Marshal.dump(self)) > end > end > > I get the following (irb 0.9(02/07/03)) > > irb(main):001:0> fmt = "%m-%d-%Y %H:%M" > => "%m-%d-%Y %H:%M" > irb> original = Time.gm(2004, 04, 25, 22, 56) > => Sun Apr 25 22:56:00 UTC 2004 > irb> copy = original.deep_copy > => Sun Apr 25 18:56:00 Eastern Daylight Time 2004 > irb> [original, copy].map {|t| t.strftime(fmt)} > => ["04-25-2004 22:56", "04-25-2004 18:56"] > irb> original.hour > => 22 > irb> copy.hour > => 18 > irb> original.hour <=> copy.hour > => 1 > irb> original <=> copy > => 0 Not as bad as all that; I think that it's an artifact of how Time is constructed, not in Marshal. If you know you're dealing with Time, and want deal only with UTC (GMT) times, do: copy = original.deep_copy.utc Logically, copy.zone should be the same as original.zone, but as I said, I think that's a Time problem. -austin -- austin ziegler * austin.ziegler@evault.com