aboutsummaryrefslogtreecommitdiffstats
path: root/activesupport/lib/active_support/values
diff options
context:
space:
mode:
authorGeoff Buesing <gbuesing@gmail.com>2008-03-17 02:40:28 +0000
committerGeoff Buesing <gbuesing@gmail.com>2008-03-17 02:40:28 +0000
commit77ee522bf6c97352485fad3b72866f7ab424ecaf (patch)
treeae6684b38fce4c18cc46e4103f32cee92f8fc1da /activesupport/lib/active_support/values
parent1b41178a836ae84cf62a11ebd6bd640fd0d09566 (diff)
downloadrails-77ee522bf6c97352485fad3b72866f7ab424ecaf.tar.gz
rails-77ee522bf6c97352485fad3b72866f7ab424ecaf.tar.bz2
rails-77ee522bf6c97352485fad3b72866f7ab424ecaf.zip
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
Diffstat (limited to 'activesupport/lib/active_support/values')
-rw-r--r--activesupport/lib/active_support/values/time_zone.rb10
1 files changed, 2 insertions, 8 deletions
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