Skip to content

Commit

Permalink
Precompute TimeZone.us_zones [#199 state:resolved]
Browse files Browse the repository at this point in the history
Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information
Martin Eisenhardt authored and josh committed May 15, 2008
1 parent 802034f commit fc02eab
Showing 1 changed file with 4 additions and 5 deletions.
9 changes: 4 additions & 5 deletions activesupport/lib/active_support/values/time_zone.rb
Expand Up @@ -325,6 +325,9 @@ def tzinfo
ZONES.sort!
ZONES.freeze
ZONES_MAP.freeze

US_ZONES = ZONES.find_all { |z| z.name =~ /US|Arizona|Indiana|Hawaii|Alaska/ }
US_ZONES.freeze
end

class << self
Expand Down Expand Up @@ -361,14 +364,10 @@ def [](arg)
end
end

# A regular expression that matches the names of all time zones in
# the USA.
US_ZONES = /US|Arizona|Indiana|Hawaii|Alaska/.freeze

# A convenience method for returning a collection of TimeZone objects
# for time zones in the USA.
def us_zones
all.find_all { |z| z.name =~ US_ZONES }
US_ZONES
end
end
end

0 comments on commit fc02eab

Please sign in to comment.