public
Description: Ruby on Rails
Homepage: http://rubyonrails.org
Clone URL: git://github.com/rails/rails.git
Fix TimeWithZone unmarshaling: coerce unmarshaled Time instances to utc, because 
Ruby's marshaling of Time instances doesn't respect the zone
gbuesing (author)
Mon Jul 14 21:26:48 -0700 2008
commit  e6ad7ff466f045b30c7b07e8ee5f3865c9604687
tree    076cd1017b4e935b89905dc29074c7ae721ebb41
parent  6e58a254942eb6d7b508452bb7b5b418607dc272
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *2.1.1 (next release)*
0
 
0
+* Fix TimeWithZone unmarshaling: coerce unmarshaled Time instances to utc, because Ruby's marshaling of Time instances doesn't respect the zone [Geoff Buesing]
0
+
0
 * Added StringQuestioneer for doing things like StringQuestioneer.new("production").production? # => true and StringQuestioneer.new("production").development? # => false [DHH]
0
 
0
 * Fixed Date#end_of_quarter to not blow up on May 31st [#289 state:resolved] (Danger)
...
246
247
248
249
 
250
251
252
...
246
247
248
 
249
250
251
252
0
@@ -246,7 +246,7 @@ module ActiveSupport
0
     end
0
     
0
     def marshal_load(variables)
0
-      initialize(variables[0], ::Time.send!(:get_zone, variables[1]), variables[2])
0
+      initialize(variables[0].utc, ::Time.send!(:get_zone, variables[1]), variables[2].utc)
0
     end
0
 
0
     # Ensure proxy class responds to all methods that underlying time instance responds to.
...
320
321
322
 
323
324
 
 
325
326
327
...
331
332
333
 
334
335
 
 
336
337
338
...
320
321
322
323
324
325
326
327
328
329
330
...
334
335
336
337
338
339
340
341
342
343
344
0
@@ -320,8 +320,11 @@ class TimeWithZoneTest < Test::Unit::TestCase
0
       marshal_str = Marshal.dump(@twz)
0
       mtime = Marshal.load(marshal_str)
0
       assert_equal Time.utc(2000, 1, 1, 0), mtime.utc
0
+      assert mtime.utc.utc?
0
       assert_equal ActiveSupport::TimeZone['Eastern Time (US & Canada)'], mtime.time_zone
0
       assert_equal Time.utc(1999, 12, 31, 19), mtime.time
0
+      assert mtime.time.utc?
0
+      assert_equal @twz.inspect, mtime.inspect
0
     end
0
   end
0
 
0
@@ -331,8 +334,11 @@ class TimeWithZoneTest < Test::Unit::TestCase
0
       marshal_str = Marshal.dump(twz)
0
       mtime = Marshal.load(marshal_str)
0
       assert_equal Time.utc(2000, 1, 1, 0), mtime.utc
0
+      assert mtime.utc.utc?
0
       assert_equal 'America/New_York', mtime.time_zone.name
0
       assert_equal Time.utc(1999, 12, 31, 19), mtime.time
0
+      assert mtime.time.utc?
0
+      assert_equal @twz.inspect, mtime.inspect
0
     end
0
   end
0
 

Comments