timezone - Better python datetime display? -


i'm using babel , pytz time zones. however, of america, maps not helpful in dropdown box:

"america/new_york" displays "eastern time", "america/nipigon" displays "eastern time".

is there way conversion add city info? other timezones seems okay, "asia/jakarta" converts "indonesia (jakarta) time"

works me babel 0.9.5 , pytz 2010b.

py.tz

#!/usr/bin/env python  import pytz import babel.dates  tz = pytz.timezone('america/new_york') print babel.dates.get_timezone_location(tz) 

output

$ python tz.py  united states (new york) time 

how running it? versions?


if stuck versions have, why not use continent/city entries?

here's starting point you. determines both continent , city, can format want.

tzs.py

#!/usr/bin/env python  import pytz import babel.dates import re  country_timezones = {} (country, tzlist) in pytz.country_timezones.iteritems():     country_name = pytz.country_names[country]     cities = []     timezone in tzlist:         # remove continent         city = re.sub(r'^[^/]*/', r'', timezone)         # argentina has "argentina/" on system (pytz 2010b)         city = re.sub(country_name + '/', '', city)         # indiana , north dakota have different rules country         # change indiana/location location, indiana         city = re.sub(r'^([^/]*)/(.*)', r'\2, \1', city)         # change underscores spaces         city = re.sub(r'_', r' ', city)         cities.append(city)       country_timezones[country_name] = cities  country in sorted(country_timezones):     print country     city in sorted(country_timezones[country]):         print "\t%s" % (city) 

output

aaland islands         mariehamn afghanistan         kabul ... indonesia         jakarta         jayapura         makassar         pontianak ... united states         adak         anchorage         boise         center, north dakota         chicago         denver         detroit 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -