[FRPythoneers] how to list timezone names?

Matt Gushee mgushee at havenrock.com
Thu Sep 5 09:25:05 MDT 2002


On Thu, Sep 05, 2002 at 09:10:38AM -0600, Eric Brunson wrote:
> * Wostenberg (pwos at attbi.com) [020905 09:01]:
> > I'm doing a Python method in Zope Linux server that shows a list of 
> > possible timezones (US/Pacific, US/Eastern, etc.) for use with the time 
> > functions. So far I've hard wired this
> > # timezones: Return a list of strings that are timezones
> > tz = ["US/Mountain", "US/Pacific", "US/Central", "US/Eastern", "Other"]
> > return tz
> > 
> > because I couldn't find a function in the times package. Is there a 
> > function?
> 
> Those names are the names of zoneinfo files.
> 
> ls /usr/share/zoneinfo/US
> 
> Those files are installed as part of glibc-common on RedHat, so I
> think any standard API for listing available zones would be in the
> glibc documentation.

I am normally eager to rant against hard-coding anything, but in this
case I think it makes sense. After all, the time zones of the world
don't change too often, and using glibc introduces needless complexity
and makes your code less portable. Or is there some reason your
application might need to display a varying set of timezones according
to the platform, location, or ...?

-- 
Matt Gushee
Englewood, Colorado, USA
mgushee at havenrock.com
http://www.havenrock.com/



More information about the FRPythoneers mailing list