Class: Barometer::Utils::ZoneCodeLookup
- Inherits:
-
Object
- Object
- Barometer::Utils::ZoneCodeLookup
- Defined in:
- lib/barometer/utils/zone_code_lookup.rb
Constant Summary collapse
- @@zone_codes_file =
File.( File.join(File.dirname(__FILE__), 'translations', 'zone_codes.yml'))
- @@zone_codes =
nil
Class Method Summary collapse
- ._load_zone_codes ⇒ Object
- .exists?(code) ⇒ Boolean
-
.offset(code) ⇒ Object
Known conflicts: IRT (ireland and india) CST (central standard time, china standard time).
Class Method Details
._load_zone_codes ⇒ Object
8 9 10 11 |
# File 'lib/barometer/utils/zone_code_lookup.rb', line 8 def self._load_zone_codes $:.unshift(File.dirname(__FILE__)) @@zone_codes ||= YAML.load_file(@@zone_codes_file) end |
.exists?(code) ⇒ Boolean
13 14 15 16 |
# File 'lib/barometer/utils/zone_code_lookup.rb', line 13 def self.exists?(code) _load_zone_codes unless @@zone_codes (::Time.zone_offset(code.to_s) || @@zone_codes && @@zone_codes.has_key?(code)) end |
.offset(code) ⇒ Object
Known conflicts: IRT (ireland and india) CST (central standard time, china standard time)
22 23 24 25 26 27 |
# File 'lib/barometer/utils/zone_code_lookup.rb', line 22 def self.offset(code) # http://www.timeanddate.com/library/abbreviations/timezones/ # http://www.worldtimezone.com/wtz-names/timezonenames.html _load_zone_codes unless @@zone_codes ::Time.zone_offset(code) || ((@@zone_codes[code.to_s.upcase] || 0) * 60 * 60) end |