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

Changeset 8853

Show
Ignore:
Timestamp:
02/10/08 20:35:47 (7 months ago)
Author:
gbuesing
Message:

TimeWithZone #in_time_zone returns +self+ if zone argument is the same as #time_zone

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/activesupport/CHANGELOG

    r8852 r8853  
    11*SVN* 
     2 
     3* TimeWithZone #in_time_zone returns +self+ if zone argument is the same as #time_zone [Geoff Buesing] 
    24 
    35* Adding TimeWithZone #to_a, #to_f, #to_i, #httpdate, #rfc2822 [Geoff Buesing] 
  • trunk/activesupport/lib/active_support/time_with_zone.rb

    r8852 r8853  
    3030    # Returns the simultaneous time in the specified zone 
    3131    def in_time_zone(new_zone) 
     32      return self if time_zone == new_zone 
    3233      utc.in_time_zone(new_zone) 
    3334    end 
  • trunk/activesupport/test/core_ext/time_with_zone_test.rb

    r8852 r8853  
    2525    def test_in_time_zone 
    2626      assert_equal ActiveSupport::TimeWithZone.new(@utc, TimeZone['Alaska']), @twz.in_time_zone('Alaska') 
     27    end 
     28     
     29    def test_in_time_zone_with_new_zone_equal_to_old_zone_does_not_create_new_object 
     30      assert_equal @twz.object_id, @twz.in_time_zone(TimeZone['Eastern Time (US & Canada)']).object_id 
    2731    end 
    2832