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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file tzcity-0.0.3.tar.gz.

File metadata

  • Download URL: tzcity-0.0.3.tar.gz
  • Upload date:
  • Size: 11.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for tzcity-0.0.3.tar.gz
Algorithm Hash digest
SHA256 5a085e6724a1edd7859e7780a6f3f65967c50e6badec06fd99956e3f06b5d168
MD5 3671d588167501740680e8ca5f279c25
BLAKE2b-256 e6bc8ddef8d41749285c89957ef73b88d208a470bd3a5cb81a42eb0d7043dd8e

See more details on using hashes here.

File details

Details for the file tzcity-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: tzcity-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 8.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: python-requests/2.24.0

File hashes

Hashes for tzcity-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 318d1703c045d4b1a736bc97ae207b37bb8bc391327b712c936b3fc2fe261019
MD5 c7de42c60aa786331b8c80b9c446611d
BLAKE2b-256 b0da262a8ba49552af936228c6086bb32770cd1f884932d483e1f68ad58f7cb0

See more details on using hashes here.

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