Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

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  
    3434  end 
    3535 
    3636  def test_adjust_negative 
    37     zone = TimeZone.create( "Test", -4200 ) 
     37    zone = TimeZone.create( "Test", -4200 ) # 4200s == 70 mins 
    3838    assert_equal Time.utc(2004,7,24,23,55,0), zone.adjust(Time.utc(2004,7,25,1,5,0)) 
    3939  end 
    4040 
  • lib/active_support/values/time_zone.rb

    old new  
    4545 
    4646  # Adjust the given time to the time zone represented by +self+. 
    4747  def adjust(time) 
    48     time = time.to_time 
     48    time = time.to_time unless time.is_a?(::Time) 
    4949    time + utc_offset - time.utc_offset 
    5050  end 
    5151 
     
    5353  # zone, and then adjusts it to return the corresponding time in the 
    5454  # local time zone. 
    5555  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 
    5859  end 
    5960 
    6061  # Compare this time zone to the parameter. The two are comapred first on