On 23/10/2007, Sanjay Vakil <[EMAIL PROTECTED]> 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
_______________________________________________
TZInfo-users mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/tzinfo-users

Reply via email to