From a7adca3d3b53df69cf45756f0459e501ee44d469 Mon Sep 17 00:00:00 2001
From: Geoff Buesing <gbuesing@gmail.com>
Date: Fri, 25 Jan 2008 16:12:43 +0000
Subject: Time.get_zone refactored to private method, given that the
 encapsulated logic is only useful internally

git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@8719 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
---
 activesupport/CHANGELOG                                |  2 ++
 .../lib/active_support/core_ext/time/zones.rb          | 18 ++++++++++++------
 2 files changed, 14 insertions(+), 6 deletions(-)

diff --git a/activesupport/CHANGELOG b/activesupport/CHANGELOG
index ed9f8a8e00..7103d726af 100644
--- a/activesupport/CHANGELOG
+++ b/activesupport/CHANGELOG
@@ -1,5 +1,7 @@
 *SVN*
 
+* Time.get_zone refactored to private method, given that the encapsulated logic is only useful internally [Geoff Buesing]
+
 * Time.zone uses thread-local variable for thread safety. Adding Time.use_zone, for overriding Time.zone locally inside a block. Removing unneeded Time.zone_reset! [Geoff Buesing]
 
 * TimeZone#to_s uses UTC rather than GMT; reapplying change that was undone in [8679]. #1689 [Cheah Chu Yeow]
diff --git a/activesupport/lib/active_support/core_ext/time/zones.rb b/activesupport/lib/active_support/core_ext/time/zones.rb
index a600e4099d..7b9106b4ac 100644
--- a/activesupport/lib/active_support/core_ext/time/zones.rb
+++ b/activesupport/lib/active_support/core_ext/time/zones.rb
@@ -28,15 +28,16 @@ module ActiveSupport #:nodoc:
           
           # Allows override of Time.zone locally inside supplied block; resets Time.zone to existing value when done
           def use_zone(time_zone)
-            old_zone, ::Time.zone = ::Time.zone, ::Time.get_zone(time_zone)
+            old_zone, ::Time.zone = ::Time.zone, get_zone(time_zone)
             yield
           ensure
             ::Time.zone = old_zone
           end
           
-          def get_zone(time_zone)
-            ::String === time_zone || ::Numeric === time_zone ? TimeZone[time_zone] : time_zone
-          end
+          private
+            def get_zone(time_zone)
+              ::String === time_zone || ::Numeric === time_zone ? TimeZone[time_zone] : time_zone
+            end
         end
         
         # Gives the corresponding time in the supplied zone. self is assumed to be in UTC regardless of constructor.
@@ -47,7 +48,7 @@ module ActiveSupport #:nodoc:
         #   t.in_time_zone('Alaska')  # => Fri, 31 Dec 1999 15:00:00 AKST -09:00
         #   t.in_time_zone('Hawaii')  # => Fri, 31 Dec 1999 14:00:00 HST -10:00
         def in_time_zone(zone)
-          ActiveSupport::TimeWithZone.new(self, ::Time.get_zone(zone))
+          ActiveSupport::TimeWithZone.new(self, get_zone(zone))
         end
 
         # Returns the simultaneous time in Time.zone
@@ -61,13 +62,18 @@ module ActiveSupport #:nodoc:
         #   t.change_time_zone('Alaska')  # => Sat, 01 Jan 2000 00:00:00 AKST -09:00
         #   t.change_time_zone('Hawaii')  # => Sat, 01 Jan 2000 00:00:00 HST -10:00
         def change_time_zone(zone)
-          ActiveSupport::TimeWithZone.new(nil, ::Time.get_zone(zone), self)
+          ActiveSupport::TimeWithZone.new(nil, get_zone(zone), self)
         end
 
         # Replaces the existing zone to Time.zone; leaves time value intact
         def change_time_zone_to_current
           ::Time.zone ? change_time_zone(::Time.zone) : self
         end
+        
+        private
+          def get_zone(time_zone)
+            ::Time.send!(:get_zone, time_zone)
+          end
       end
     end
   end
-- 
cgit v1.2.3