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

Changeset 8708

Show
Ignore:
Timestamp:
01/23/08 18:49:54 (7 months ago)
Author:
gbuesing
Message:

Time #in_current_time_zone and #change_time_zone_to_current return self when Time.zone is nil

Files:

Legend:

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

    r8705 r8708  
    11*SVN* 
     2 
     3* Time #in_current_time_zone and #change_time_zone_to_current return self when Time.zone is nil [Geoff Buesing] 
    24 
    35* Remove unneeded #to_datetime_default_s alias for DateTime#to_s, given that we inherit a #to_default_s from Date that does exactly the same thing [Geoff Buesing] 
  • trunk/activesupport/lib/active_support/core_ext/time/zones.rb

    r8696 r8708  
    4747        # Returns the simultaneous time in Time.zone 
    4848        def in_current_time_zone 
    49           in_time_zone(::Time.zone) 
     49          ::Time.zone ? in_time_zone(::Time.zone) : self 
    5050        end 
    5151 
     
    6161        # Replaces the existing zone to Time.zone; leaves time value intact 
    6262        def change_time_zone_to_current 
    63           change_time_zone(::Time.zone) 
     63          ::Time.zone ? change_time_zone(::Time.zone) : self 
    6464        end 
    6565      end 
  • trunk/activesupport/test/core_ext/time_with_zone_test.rb

    r8696 r8708  
    171171      end 
    172172      with_time_zone nil do 
    173         assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @t.in_current_time_zone.inspect 
    174         assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @dt.in_current_time_zone.inspect 
     173        assert_equal @t, @t.in_current_time_zone 
     174        assert_equal @dt, @dt.in_current_time_zone 
    175175      end 
    176176    end 
     
    197197      end 
    198198      with_time_zone nil do 
    199         assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @t.change_time_zone_to_current.inspec
    200         assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @dt.change_time_zone_to_current.inspec
     199        assert_equal @t, @t.change_time_zone_to_curren
     200        assert_equal @dt, @dt.change_time_zone_to_curren
    201201      end 
    202202    end