Chris V. Chris V. - 6 months ago 15
Ruby Question

Filter out TZInfo:Timezone Ruby results to exclude

I want to filter out the timezones TZInfo provides so I can exclude the values that are formatted like

(GMT +03:00) Nairobi
which are not compatible with the 95% of the locations there (Europe - Sofia, US - Central etc.).

<%= f.time_zone_select :system_locale, TZInfo::Timezone.all.sort, {}, {:class => 'ui fluid search dropdown'} %>


How can I achieve this ?

Answer

You can try this:

TZInfo::Timezone.all.select {|k| !k.name.include?("GMT")}
Comments