[TZInfo-users] more generic names?
Philip Ross
phil.ross at gmail.com
Tue Oct 23 05:32:00 EDT 2007
On 23/10/2007, Sanjay Vakil <svakil at gmail.com> wrote:
> > There is no link from a timezone to the country or countries that use
> > it. You could use the information available through the Country class
> > to build such an index though.
>
> This is the bit I couldn't figure out. Could you elucidate?
The following code will give you a hash mapping timezone identifiers
to the country that uses that timezone.
TZInfo::Country.all.inject({}) do |zones,country|
country.zone_identifiers.each {|zone_id| zones[zone_id] = country}
zones
end
The hash won't contain every timezone - just those that are defined as
part of a country.
Phil
--
Phil Ross
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby
More information about the TZInfo-users
mailing list