Created
June 20, 2014 21:24
-
-
Save kueda/3e6f77f64f792b4f119f to your computer and use it in GitHub Desktop.
Took me a while to figure out how to get at all the time zone abbreviations stored within the TZInfo gem. I'm sure there's a better way, but this works.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment