Module to translate city names to time zone names
A module to find the Olson database time zone names of some of the most populous cities in the world without an internet connection.
Only a few cities associated with each time zone are recognized to minimize the size of data bundled with the package.
You need Python>=3.6 to use tzcity.
It can be installed from PyPI with pip using
pip install tzcity
tzcity.tzcity(city: str) -> str
Accepts a city name and returns the time zone name associated with that city.
UnknownTZCityException if unable to recognize city.
>>> tzcity.tzcity('abu dhabi') 'Asia/Dubai' >>> tzcity.tzcity('bandar seri begawan') 'Asia/Brunei' >>> tzcity.tzcity('myanmar') # a country with only one time zone 'Asia/Yangon'
tzcity.capitalize(name: str) -> str
Capitalize the city or time zone name provided as argument.
UnknownTZCityException if unable to recognize name.
>>> tzcity.capitalize('andorra la vella') 'Andorra la Vella' >>> tzcity.capitalize("new york") 'New York' >>> tzcity.capitalize("dumont d'urville") "Dumont d'Urville"
Release history Release notifications | RSS feed
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.