Skip to main content

World timezone definitions by country subdivision (e.g., provinces or states)

Project description

pytzsub

CI PyPI version Python versions License: MIT

World timezone definitions by country subdivision (e.g., provinces or states).

Given an ISO 3166 country or subdivision code, pytzsub returns the matching IANA time zone name.

Accuracy of the database

The database is not authoritative, and it surely has errors. Corrections are welcome and encouraged.

Installation

As per usual:

pip install pytzsub

pytzsub has no runtime dependencies and supports Python 3.9+.

Examples

>>> from pytzsub import sub_timezone
>>> sub_timezone('US-CA')
'America/Los_Angeles'
>>> from pytzsub import all_code
>>> 'US-CA' in all_code()
True

Combine it with the standard-library zoneinfo module (Python 3.9+) to build a real timezone object:

>>> from zoneinfo import ZoneInfo
>>> from pytzsub import sub_timezone
>>> tz = ZoneInfo(sub_timezone('CA-QC'))
>>> tz.key
'America/Toronto'

It also works with pytz if you prefer it:

>>> from pytz import timezone
>>> from pytzsub import sub_timezone
>>> timezone(sub_timezone('CA-QC'))
<DstTzInfo 'America/Toronto' LMT-1 day, 18:28:00 STD>

Links

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

pytzsub-2026.7.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pytzsub-2026.7-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file pytzsub-2026.7.tar.gz.

File metadata

  • Download URL: pytzsub-2026.7.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pytzsub-2026.7.tar.gz
Algorithm Hash digest
SHA256 66f6a7eb186440d098315d552f536b5e8af2b5b972080a4d0e105f29e270726e
MD5 61763c6d189e8e4387b56b8a91aaa382
BLAKE2b-256 8ca97df30fcd4e86101ee6badac10181052e33ee7fe0a5fde9a241bf1fe11083

See more details on using hashes here.

File details

Details for the file pytzsub-2026.7-py3-none-any.whl.

File metadata

  • Download URL: pytzsub-2026.7-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for pytzsub-2026.7-py3-none-any.whl
Algorithm Hash digest
SHA256 6e6ce274c97eb6783be668c8c03326ba898f0ba62af1dd968ee6802b190c63f2
MD5 f1718a0c0c274f6d43f56061280dc448
BLAKE2b-256 201b57d3991c859f012822424c3d5bd4828c4a962f63ce6fc55fcc594e3ae95a

See more details on using hashes here.

Supported by

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