Changeset 8849
- Timestamp:
- 02/10/08 18:45:55 (7 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
r8848 r8849 1 1 *SVN* 2 3 * Time#in_time_zone handles Time.local instances correctly [Geoff Buesing] 2 4 3 5 * 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] trunk/activesupport/lib/active_support/core_ext/time/zones.rb
r8848 r8849 43 43 end 44 44 45 # Returns the simultaneous time in the supplied zone. self is assumed to be in UTC regardless of constructor. 46 # 47 # Examples: 45 # Returns the simultaneous time in the supplied zone. Examples: 48 46 # 49 47 # t = Time.utc(2000) # => Sat Jan 01 00:00:00 UTC 2000 … … 51 49 # t.in_time_zone('Hawaii') # => Fri, 31 Dec 1999 14:00:00 HST -10:00 52 50 def in_time_zone(zone) 53 ActiveSupport::TimeWithZone.new( self, get_zone(zone))51 ActiveSupport::TimeWithZone.new(utc? ? self : getutc, get_zone(zone)) 54 52 end 55 53 trunk/activesupport/test/core_ext/time_with_zone_test.rb
r8848 r8849 175 175 end 176 176 end 177 178 def test_in_time_zone_with_time_local_instance 179 silence_warnings do # silence warnings raised by tzinfo gem 180 with_env_tz 'US/Eastern' do 181 time = Time.local(1999, 12, 31, 19) # == Time.utc(2000) 182 assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', time.in_time_zone('Alaska').inspect 183 end 184 end 185 end 177 186 178 187 def test_in_current_time_zone … … 229 238 end 230 239 end 240 241 protected 242 def with_env_tz(new_tz = 'US/Eastern') 243 old_tz, ENV['TZ'] = ENV['TZ'], new_tz 244 yield 245 ensure 246 old_tz ? ENV['TZ'] = old_tz : ENV.delete('TZ') 247 end 231 248 end 232 249 end