aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/core_ext
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-01-25 16:12:43 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-01-25 16:12:43 +0000
commita7adca3d3b53df69cf45756f0459e501ee44d469 (patch)
tree82b9b4d286a258878286a350a5d41464e2e8b366 /activesupport/lib/active_support/core_ext
parentc911e1ac08d119e94fcec6973a012f4cd198ecee (diff)
downloadrails-a7adca3d3b53df69cf45756f0459e501ee44d469.tar.gz
rails-a7adca3d3b53df69cf45756f0459e501ee44d469.tar.bz2
rails-a7adca3d3b53df69cf45756f0459e501ee44d469.zip
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
Diffstat (limited to 'activesupport/lib/active_support/core_ext')
-rw-r--r--activesupport/lib/active_support/core_ext/time/zones.rb18
1 files changed, 12 insertions, 6 deletions
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