public
Fork of NZKoz/koz-rails
Description: Koz's rails git-svn clone
Homepage: http://www.rubyonrails.org
Clone URL: git://github.com/eventualbuddha/koz-rails.git
Removing unneeded #change_time_zone method from Time, DateTime and 
TimeWithZone

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9008 
5ecf4fe2-1ee6-0310-87b1-e25e094e27de
gbuesing (author)
Mon Mar 10 23:23:41 -0700 2008
commit  070dfb45338573d7b7239cfe08830cdd719dcb63
tree    901c6977bf653302977f3bf55d1b68f4232921fb
parent  6a4380cc2eece7a8dab07975843dbeb69e235692
...
1
2
 
 
3
4
5
...
1
2
3
4
5
6
7
0
@@ -1,5 +1,7 @@
0
 *SVN*
0
 
0
+* Removing unneeded #change_time_zone method from Time, DateTime and TimeWithZone [Geoff Buesing]
0
+
0
 * TimeZone #local and #now correctly enforce DST rules [Geoff Buesing]
0
 
0
 * TimeWithZone instances correctly enforce DST rules. Adding TimeZone#period_for_utc [Geoff Buesing]
...
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
...
56
57
58
 
 
 
 
 
 
 
 
 
 
 
 
 
59
60
61
0
@@ -56,19 +56,6 @@ module ActiveSupport #:nodoc:
0
         def in_current_time_zone
0
           ::Time.zone ? in_time_zone(::Time.zone) : self
0
         end
0
-
0
- # Replaces the existing zone; leaves time values intact. Examples:
0
- #
0
- # t = Time.utc(2000) # => Sat Jan 01 00:00:00 UTC 2000
0
- # t.change_time_zone('Alaska') # => Sat, 01 Jan 2000 00:00:00 AKST -09:00
0
- # t.change_time_zone('Hawaii') # => Sat, 01 Jan 2000 00:00:00 HST -10:00
0
- #
0
- # Note the difference between this method and #in_time_zone: #in_time_zone does a calculation to determine
0
- # the simultaneous time in the supplied zone, whereas #change_time_zone does no calculation; it just
0
- # "dials in" a new time zone for +self+
0
- def change_time_zone(zone)
0
- ActiveSupport::TimeWithZone.new(nil, get_zone(zone), self)
0
- end
0
         
0
         private
0
           def get_zone(time_zone)
...
41
42
43
44
45
46
47
48
49
50
51
...
41
42
43
 
 
 
 
 
44
45
46
0
@@ -41,11 +41,6 @@ module ActiveSupport
0
       utc.in_current_time_zone
0
     end
0
   
0
- # Changes the time zone without converting the time
0
- def change_time_zone(new_zone)
0
- time.change_time_zone(new_zone)
0
- end
0
-
0
     # Returns a Time.local() instance of the simultaneous time in your system's ENV['TZ'] zone
0
     def localtime
0
       utc.getlocal
...
36
37
38
39
40
41
42
43
44
45
46
47
...
53
54
55
56
57
 
 
 
 
58
59
60
...
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
 
 
 
 
 
 
 
 
 
 
 
322
323
324
...
36
37
38
 
 
 
 
 
 
39
40
41
...
47
48
49
 
 
50
51
52
53
54
55
56
...
291
292
293
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
294
 
 
 
 
 
 
 
 
295
296
297
298
299
300
301
302
303
304
305
306
307
308
0
@@ -36,12 +36,6 @@ uses_tzinfo 'TimeWithZoneTest' do
0
       end
0
     end
0
   
0
- def test_change_time_zone
0
- silence_warnings do # silence warnings raised by tzinfo gem
0
- assert_equal ActiveSupport::TimeWithZone.new(nil, TimeZone['Alaska'], Time.utc(1999, 12, 31, 19)), @twz.change_time_zone('Alaska')
0
- end
0
- end
0
-
0
     def test_utc?
0
       assert_equal false, @twz.utc?
0
       assert_equal true, ActiveSupport::TimeWithZone.new(Time.utc(2000), TimeZone['UTC']).utc?
0
@@ -53,8 +47,10 @@ uses_tzinfo 'TimeWithZoneTest' do
0
     end
0
       
0
     def test_dst?
0
- assert_equal false, @twz.dst?
0
- assert_equal true, ActiveSupport::TimeWithZone.new(Time.utc(2000, 6), @time_zone).dst?
0
+ silence_warnings do # silence warnings raised by tzinfo gem
0
+ assert_equal false, @twz.dst?
0
+ assert_equal true, ActiveSupport::TimeWithZone.new(Time.utc(2000, 6), @time_zone).dst?
0
+ end
0
     end
0
       
0
     def test_zone
0
@@ -295,30 +291,18 @@ uses_tzinfo 'TimeWithZoneTest' do
0
     end
0
 
0
     def test_in_current_time_zone
0
- Time.use_zone 'Alaska' do
0
- assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @t.in_current_time_zone.inspect
0
- assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @dt.in_current_time_zone.inspect
0
- end
0
- Time.use_zone 'Hawaii' do
0
- assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @t.in_current_time_zone.inspect
0
- assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @dt.in_current_time_zone.inspect
0
- end
0
- Time.use_zone nil do
0
- assert_equal @t, @t.in_current_time_zone
0
- assert_equal @dt, @dt.in_current_time_zone
0
- end
0
- end
0
-
0
- def test_change_time_zone
0
       silence_warnings do # silence warnings raised by tzinfo gem
0
- Time.use_zone 'Eastern Time (US & Canada)' do # Time.zone will not affect #change_time_zone(zone)
0
- assert_equal 'Sat, 01 Jan 2000 00:00:00 AKST -09:00', @t.change_time_zone('Alaska').inspect
0
- assert_equal 'Sat, 01 Jan 2000 00:00:00 AKST -09:00', @dt.change_time_zone('Alaska').inspect
0
- assert_equal 'Sat, 01 Jan 2000 00:00:00 HST -10:00', @t.change_time_zone('Hawaii').inspect
0
- assert_equal 'Sat, 01 Jan 2000 00:00:00 HST -10:00', @dt.change_time_zone('Hawaii').inspect
0
- assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @t.change_time_zone('UTC').inspect
0
- assert_equal 'Sat, 01 Jan 2000 00:00:00 UTC +00:00', @dt.change_time_zone('UTC').inspect
0
- assert_equal 'Sat, 01 Jan 2000 00:00:00 AKST -09:00', @t.change_time_zone(-9.hours).inspect
0
+ Time.use_zone 'Alaska' do
0
+ assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @t.in_current_time_zone.inspect
0
+ assert_equal 'Fri, 31 Dec 1999 15:00:00 AKST -09:00', @dt.in_current_time_zone.inspect
0
+ end
0
+ Time.use_zone 'Hawaii' do
0
+ assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @t.in_current_time_zone.inspect
0
+ assert_equal 'Fri, 31 Dec 1999 14:00:00 HST -10:00', @dt.in_current_time_zone.inspect
0
+ end
0
+ Time.use_zone nil do
0
+ assert_equal @t, @t.in_current_time_zone
0
+ assert_equal @dt, @dt.in_current_time_zone
0
         end
0
       end
0
     end

Comments

    No one has commented yet.