Skip to content

Commit

Permalink
load tzinfo on initialize only
Browse files Browse the repository at this point in the history
Signed-off-by: Xavier Noria <fxn@hashref.com>
  • Loading branch information
spastorino authored and fxn committed Apr 21, 2010
1 parent 49943a7 commit d891754
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions activesupport/lib/active_support/values/time_zone.rb
Expand Up @@ -172,6 +172,7 @@ class TimeZone

include Comparable
attr_reader :name
attr_reader :tzinfo

# Create a new TimeZone object with the given name and offset. The
# offset is the number of seconds that this time zone is offset from UTC
Expand All @@ -180,7 +181,7 @@ class TimeZone
def initialize(name, utc_offset = nil, tzinfo = nil)
@name = name
@utc_offset = utc_offset
@tzinfo = tzinfo
@tzinfo = tzinfo || TimeZone.find_tzinfo(name)
@current_period = nil
end

Expand Down Expand Up @@ -292,10 +293,6 @@ def period_for_local(time, dst=true)
tzinfo.period_for_local(time, dst)
end

def tzinfo
@tzinfo ||= TimeZone.find_tzinfo(name)
end

# TODO: Preload instead of lazy load for thread safety
def self.find_tzinfo(name)
require 'tzinfo' unless defined?(TZInfo)
Expand Down

0 comments on commit d891754

Please sign in to comment.