Changeset 8848
- Timestamp:
- 02/10/08 18:20:37 (8 months ago)
- Files:
-
- trunk/activesupport/CHANGELOG (modified) (1 diff)
- trunk/activesupport/lib/active_support/core_ext/time/zones.rb (modified) (2 diffs)
- trunk/activesupport/test/core_ext/time_with_zone_test.rb (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
trunk/activesupport/CHANGELOG
r8847 r8848 1 1 *SVN* 2 3 * Pruning unneeded Time#change_time_zone_to_current. Enhanced docs to #change_time_zone to explain the difference between this method and #in_time_zone [Geoff Buesing] 2 4 3 5 * TimeZone#new method renamed #local; when used with Time.zone, constructor now reads: Time.zone.local() [Geoff Buesing] trunk/activesupport/lib/active_support/core_ext/time/zones.rb
r8806 r8848 43 43 end 44 44 45 # Gives the correspondingtime in the supplied zone. self is assumed to be in UTC regardless of constructor.45 # Returns the simultaneous time in the supplied zone. self is assumed to be in UTC regardless of constructor. 46 46 # 47 47 # Examples: … … 59 59 end 60 60 61 # Replaces the existing zone; leaves time value intact. Examples:61 # Replaces the existing zone; leaves time values intact. Examples: 62 62 # 63 63 # t = Time.utc(2000) # => Sat Jan 01 00:00:00 UTC 2000 64 64 # t.change_time_zone('Alaska') # => Sat, 01 Jan 2000 00:00:00 AKST -09:00 65 65 # t.change_time_zone('Hawaii') # => Sat, 01 Jan 2000 00:00:00 HST -10:00 66 # 67 # Note the difference between this method and #in_time_zone: #in_time_zone does a calculation to determine 68 # the simultaneous time in the supplied zone, whereas #change_time_zone does no calculation; it just 69 # "dials in" a new time zone for +self+ 66 70 def change_time_zone(zone) 67 71 ActiveSupport::TimeWithZone.new(nil, get_zone(zone), self) 68 end69 70 # Replaces the existing zone to Time.zone; leaves time value intact71 def change_time_zone_to_current72 ::Time.zone ? change_time_zone(::Time.zone) : self73 72 end 74 73 trunk/activesupport/test/core_ext/time_with_zone_test.rb
r8732 r8848 36 36 silence_warnings do # silence warnings raised by tzinfo gem 37 37 assert_equal ActiveSupport::TimeWithZone.new(nil, TimeZone['Alaska'], Time.utc(1999, 12, 31, 19)), @twz.change_time_zone('Alaska') 38 end39 end40 41 def test_change_time_zone_to_current42 Time.use_zone 'Alaska' do43 assert_equal ActiveSupport::TimeWithZone.new(nil, TimeZone['Alaska'], Time.utc(1999, 12, 31, 19)), @twz.change_time_zone_to_current44 38 end 45 39 end … … 210 204 end 211 205 212 def test_change_time_zone_to_current213 Time.use_zone 'Alaska' do214 assert_equal 'Sat, 01 Jan 2000 00:00:00 AKST -09:00', @t.change_time_zone_to_current.inspect215 assert_equal 'Sat, 01 Jan 2000 00:00:00 AKST -09:00', @dt.change_time_zone_to_current.inspect216 end217 Time.use_zone 'Hawaii' do218 assert_equal 'Sat, 01 Jan 2000 00:00:00 HST -10:00', @t.change_time_zone_to_current.inspect219 assert_equal 'Sat, 01 Jan 2000 00:00:00 HST -10:00', @dt.change_time_zone_to_current.inspect220 end221 Time.use_zone nil do222 assert_equal @t, @t.change_time_zone_to_current223 assert_equal @dt, @dt.change_time_zone_to_current224 end225 end226 227 206 def test_use_zone 228 207 Time.zone = 'Alaska'