From 77ee522bf6c97352485fad3b72866f7ab424ecaf Mon Sep 17 00:00:00 2001 From: Geoff Buesing Date: Mon, 17 Mar 2008 02:40:28 +0000 Subject: TimeWithZone caches TZInfo::TimezonePeriod used for time conversion so that it can be reused, and enforces DST rules correctly when instance is created from a local time git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@9040 5ecf4fe2-1ee6-0310-87b1-e25e094e27de --- activesupport/lib/active_support/values/time_zone.rb | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) (limited to 'activesupport/lib/active_support/values') diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index a52eee3e7c..401b669a0a 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -183,14 +183,8 @@ class TimeZone # Time.zone = "Hawaii" # => "Hawaii" # Time.zone.local(2007, 2, 1, 15, 30, 45) # => Thu, 01 Feb 2007 15:30:45 HST -10:00 def local(*args) - t = Time.utc_time(*args) - begin - result = local_to_utc(t) - rescue TZInfo::PeriodNotFound - t += 1.hour - retry - end - result.in_time_zone(self) + time = Time.utc_time(*args) + ActiveSupport::TimeWithZone.new(nil, self, time) end # Returns an ActiveSupport::TimeWithZone instance representing the current time -- cgit v1.2.3