From fc02eabf296d6edb74a95174c7322293a54c9492 Mon Sep 17 00:00:00 2001 From: Martin Eisenhardt Date: Thu, 15 May 2008 09:21:43 -0500 Subject: Precompute TimeZone.us_zones [#199 state:resolved] Signed-off-by: Joshua Peek --- activesupport/lib/active_support/values/time_zone.rb | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'activesupport/lib/active_support/values/time_zone.rb') diff --git a/activesupport/lib/active_support/values/time_zone.rb b/activesupport/lib/active_support/values/time_zone.rb index 0fa99135e2..f522b64108 100644 --- a/activesupport/lib/active_support/values/time_zone.rb +++ b/activesupport/lib/active_support/values/time_zone.rb @@ -325,6 +325,9 @@ class TimeZone 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 @@ class TimeZone 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 -- cgit v1.2.3