[TZInfo-users] more generic names?

Philip Ross phil.ross at gmail.com
Mon Oct 22 18:15:56 EDT 2007

On 22/10/2007, Sanjay Vakil <svakil at gmail.com> wrote:
> What I'd like to do is to show the "simpler" names of timezones,
> rather than the city name:
> EST instead of America/New_York
> PST instead of America/Los_Angeles
> Is there a way to derive this?
> I looked at linked_zones, thinking I could use those, but they don't
> appear to link back to the country in question, or the zone that they
> link to.

Linked timezones are just aliases to other zones. TZInfo hides the
details of the linked timezone.

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.

> At minimum, from a UI standpoint, it'd be nice to show something like:
> EST - New York

If you are interested in seeing EST/EDT, etc, then you can obtain a
TimezonePeriod object using Timezone#current_period,
Timezone#period_for_utc or Timezone#period_for_local and call its
abbreviation method.

The New York part can be obtained by calling Timezone#friendly_identifier(true)


Phil Ross
http://tzinfo.rubyforge.org/ -- DST-aware timezone library for Ruby

More information about the TZInfo-users mailing list