Skip to content
Browse files

Precompute TimeZone.us_zones [#199 state:resolved]

Signed-off-by: Joshua Peek <josh@joshpeek.com>
  • Loading branch information...
1 parent 802034f commit fc02eabf296d6edb74a95174c7322293a54c9492 @nprncbl nprncbl committed with josh May 15, 2008
Showing with 4 additions and 5 deletions.
  1. +4 −5 activesupport/lib/active_support/values/time_zone.rb
View
9 activesupport/lib/active_support/values/time_zone.rb
@@ -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
@@ -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.
Something went wrong with that request. Please try again.