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

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

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

File metadata

  • Download URL: tzcity-0.0.3a0.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.3a0.tar.gz
Algorithm Hash digest
SHA256 8b32cca830e67734887e6a3ec225732c2076c8871ac17cf78c2fb002cb425fc2
MD5 59f2cc0ab24b872337a2f9b4d673d26a
BLAKE2b-256 02c672a17941848e2e17e7f02a387b86c25eff1cac9cc945a5711779afbd975c

See more details on using hashes here.

Provenance

File details

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

File metadata

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

File hashes

Hashes for tzcity-0.0.3a0-py3-none-any.whl
Algorithm Hash digest
SHA256 426b3432f45cbf2d06ea3385b7a1de3d7a0a3763fabaa6ec3e700adc2a30e86e
MD5 b3828f2762efa293875ee204a652ad57
BLAKE2b-256 bc5e0d6cf27f1e3f50e869f2a7fb06798d101c6b7727bc8830993f867a8c32e1

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