Skip to content

Instantly share code, notes, and snippets.

@kueda
Created June 20, 2014 21:24
Show Gist options
  • Select an option

  • Save kueda/3e6f77f64f792b4f119f to your computer and use it in GitHub Desktop.

Select an option

Save kueda/3e6f77f64f792b4f119f to your computer and use it in GitHub Desktop.

Revisions

  1. kueda created this gist Jun 20, 2014.
    11 changes: 11 additions & 0 deletions time_zones_by_abbreviation.rb
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,11 @@
    abbrevs = {}
    TZInfo::Timezone.all.each do |tz|
    tz = tz.send(:real_timezone) unless tz.class == TZInfo::Timezone
    tzi = tz.send(:info)
    offsets = tzi.instance_variable_get(:@offsets)
    next if offsets.blank?
    offsets.values.each do |offset|
    abbrevs[offset.abbreviation] ||= []
    abbrevs[offset.abbreviation] << tz.identifier
    end
    end