Ticket #1689: time_zone_compat.diff
| File time_zone_compat.diff, 1.3 kB (added by chuyeow, 7 months ago) |
|---|
-
test/time_zone_test.rb
old new 34 34 end 35 35 36 36 def test_adjust_negative 37 zone = TimeZone.create( "Test", -4200 ) 37 zone = TimeZone.create( "Test", -4200 ) # 4200s == 70 mins 38 38 assert_equal Time.utc(2004,7,24,23,55,0), zone.adjust(Time.utc(2004,7,25,1,5,0)) 39 39 end 40 40 -
lib/active_support/values/time_zone.rb
old new 45 45 46 46 # Adjust the given time to the time zone represented by +self+. 47 47 def adjust(time) 48 time = time.to_time 48 time = time.to_time unless time.is_a?(::Time) 49 49 time + utc_offset - time.utc_offset 50 50 end 51 51 … … 53 53 # zone, and then adjusts it to return the corresponding time in the 54 54 # local time zone. 55 55 def unadjust(time) 56 time = Time.local(*time.to_time.to_a) 57 time - utc_offset + time.utc_offset 56 time = time.to_time unless time.is_a?(::Time) 57 time = time.localtime 58 time - utc_offset - time.utc_offset 58 59 end 59 60 60 61 # Compare this time zone to the parameter. The two are comapred first on