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.4a0.tar.gz (11.2 kB view details)

Uploaded Source

Built Distribution

tzcity-0.0.4a0-py3-none-any.whl (9.1 kB view details)

Uploaded Python 3

File details

Details for the file tzcity-0.0.4a0.tar.gz.

File metadata

  • Download URL: tzcity-0.0.4a0.tar.gz
  • Upload date:
  • Size: 11.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.9

File hashes

Hashes for tzcity-0.0.4a0.tar.gz
Algorithm Hash digest
SHA256 43ae0952caee3aa70c5ea9e6bdf89de7c793467202ed097266f2c5f843f8f52e
MD5 5cad7fca7bf16c1baec71618a4845f6c
BLAKE2b-256 447ecf84acf316f5355a9265b6a4bf3e2aea853962e4c3851d677afbc3429d15

See more details on using hashes here.

Provenance

File details

Details for the file tzcity-0.0.4a0-py3-none-any.whl.

File metadata

  • Download URL: tzcity-0.0.4a0-py3-none-any.whl
  • Upload date:
  • Size: 9.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.1.0 requests-toolbelt/0.9.1 tqdm/4.45.0 CPython/3.7.9

File hashes

Hashes for tzcity-0.0.4a0-py3-none-any.whl
Algorithm Hash digest
SHA256 7726931bf9b2f677a235ce2410f501807538beebcd0e539500187d250c69340a
MD5 8e029cb7ef2c472f5da848a41e85cc0d
BLAKE2b-256 7d8f992379a0c29fdb37faef99f65713a61154e1b0ba61baecc5fd929ac0745b

See more details on using hashes here.

Provenance

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