Skip to main content

Module to translate city names to time zone names

Project description

tzcity

PyPI Build Status License: MIT

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.

Installation

You need Python>=3.6 to use tzcity.

It can be installed from PyPI with pip using

pip install tzcity

Usage

tzcity.tzcity(city: str) -> str

Accepts a city name and returns the time zone name associated with that city.

Raises 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.

Raises 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"

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

tzcity-0.0.3.tar.gz (11.1 kB view hashes)

Uploaded Source

Built Distribution

tzcity-0.0.3-py3-none-any.whl (8.7 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page