Class: TwitterCldr::Timezones::ZoneMeta
- Inherits:
-
Object
- Object
- TwitterCldr::Timezones::ZoneMeta
- Defined in:
- lib/twitter_cldr/timezones/zone_meta.rb
Constant Summary collapse
- WORLD =
'001'.freeze
Class Method Summary collapse
- .canonical_country_for(tz_id) ⇒ Object
- .is_primary_region?(region_code, tz_id) ⇒ Boolean
- .normalize(tz_id) ⇒ Object
- .region_for_tz(tz_id) ⇒ Object
- .short_name_for(tz_id) ⇒ Object
- .tz_metazone_for(tz_id, date) ⇒ Object
- .tz_metazones_for(tz_id) ⇒ Object
Class Method Details
.canonical_country_for(tz_id) ⇒ Object
81 82 83 84 85 |
# File 'lib/twitter_cldr/timezones/zone_meta.rb', line 81 def canonical_country_for(tz_id) region = region_for_tz(tz_id) return nil if region == WORLD region end |
.is_primary_region?(region_code, tz_id) ⇒ Boolean
93 94 95 96 97 98 99 |
# File 'lib/twitter_cldr/timezones/zone_meta.rb', line 93 def is_primary_region?(region_code, tz_id) if region = regions_resource[tz_id.to_sym] return region[:primary] && region[:region] == region_code end false end |
.normalize(tz_id) ⇒ Object
72 73 74 75 |
# File 'lib/twitter_cldr/timezones/zone_meta.rb', line 72 def normalize(tz_id) tz_id = tz_id.to_s.strip bcp47_aliases[tz_id.to_sym] || tz_id end |
.region_for_tz(tz_id) ⇒ Object
87 88 89 90 91 |
# File 'lib/twitter_cldr/timezones/zone_meta.rb', line 87 def region_for_tz(tz_id) if region = regions_resource[tz_id.to_sym] region[:region] end end |
.short_name_for(tz_id) ⇒ Object
77 78 79 |
# File 'lib/twitter_cldr/timezones/zone_meta.rb', line 77 def short_name_for(tz_id) bcp47_short_names[tz_id.to_sym] end |
.tz_metazone_for(tz_id, date) ⇒ Object
105 106 107 |
# File 'lib/twitter_cldr/timezones/zone_meta.rb', line 105 def (tz_id, date) (tz_id).find { |mz| mz.includes?(date) } end |
.tz_metazones_for(tz_id) ⇒ Object
101 102 103 |
# File 'lib/twitter_cldr/timezones/zone_meta.rb', line 101 def (tz_id) [tz_id.to_sym] || [] end |