Class: TimeZoneUtility
- Inherits:
-
Object
- Object
- TimeZoneUtility
- Defined in:
- app/lib/time_zone_utility.rb
Class Method Summary collapse
- .format_time_zones_for_select(zones) ⇒ Object
- .seconds_to_utc_offset(seconds) ⇒ Object
- .time_zones_for_country_iso(iso) ⇒ Object
- .time_zones_for_country_iso3(iso3) ⇒ Object
- .time_zones_for_select ⇒ Object
Class Method Details
.format_time_zones_for_select(zones) ⇒ Object
19 20 21 |
# File 'app/lib/time_zone_utility.rb', line 19 def format_time_zones_for_select(zones) zones.map{|tz| ["#{tz} (UTC #{seconds_to_utc_offset(tz.utc_offset)})",tz.name]} end |
.seconds_to_utc_offset(seconds) ⇒ Object
23 24 25 |
# File 'app/lib/time_zone_utility.rb', line 23 def seconds_to_utc_offset(seconds) ActiveSupport::TimeZone.seconds_to_utc_offset(seconds) end |
.time_zones_for_country_iso(iso) ⇒ Object
9 10 11 12 |
# File 'app/lib/time_zone_utility.rb', line 9 def time_zones_for_country_iso(iso) c = TZInfo::Country.get(iso) format_time_zones_for_select c.zones end |
.time_zones_for_country_iso3(iso3) ⇒ Object
14 15 16 17 |
# File 'app/lib/time_zone_utility.rb', line 14 def time_zones_for_country_iso3(iso3) ic = ISO3166::Country.find_country_by_alpha3(iso3).alpha2 time_zones_for_country_iso ic.alpha2 end |
.time_zones_for_select ⇒ Object
5 6 7 |
# File 'app/lib/time_zone_utility.rb', line 5 def time_zones_for_select format_time_zones_for_select TZInfo::Timezone.all_country_zones end |