Metadata-Version: 2.4
Name: pytzsub
Version: 2026.7
Summary: World timezone definitions by country subdivision (e.g., provinces or states)
Project-URL: Homepage, https://github.com/maxim-s-barabash/pytzsub
Project-URL: Source, https://github.com/maxim-s-barabash/pytzsub
Project-URL: Changelog, https://github.com/maxim-s-barabash/pytzsub/blob/master/CHANGELOG.md
Project-URL: Tracker, https://github.com/maxim-s-barabash/pytzsub/issues
Author-email: Barabash Maxim <maxim.s.barabash@gmail.com>
Maintainer-email: Barabash Maxim <maxim.s.barabash@gmail.com>
License-Expression: MIT
License-File: LICENSE
Keywords: datetime,pytz,time,timezone,tzinfo,zoneinfo
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Developers
Classifier: Natural Language :: English
Classifier: Operating System :: OS Independent
Classifier: Programming Language :: Python
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3 :: Only
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Programming Language :: Python :: 3.13
Classifier: Topic :: Software Development :: Libraries :: Python Modules
Requires-Python: >=3.9
Provides-Extra: dev
Requires-Dist: build; extra == 'dev'
Requires-Dist: pytest>=7; extra == 'dev'
Requires-Dist: ruff>=0.5; extra == 'dev'
Requires-Dist: twine; extra == 'dev'
Description-Content-Type: text/markdown

# pytzsub

[![CI](https://github.com/maxim-s-barabash/pytzsub/actions/workflows/ci.yml/badge.svg)](https://github.com/maxim-s-barabash/pytzsub/actions/workflows/ci.yml)
[![PyPI version](https://img.shields.io/pypi/v/pytzsub.svg)](https://pypi.org/project/pytzsub/)
[![Python versions](https://img.shields.io/pypi/pyversions/pytzsub.svg)](https://pypi.org/project/pytzsub/)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://opensource.org/licenses/MIT)

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

Given an [ISO 3166](https://en.wikipedia.org/wiki/ISO_3166-2) country or
subdivision code, `pytzsub` returns the matching [IANA time zone][iana] name.

## Accuracy of the database

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

## Installation

As per usual:

```shell
pip install pytzsub
```

`pytzsub` has no runtime dependencies and supports Python 3.9+.

## Examples

```python
>>> from pytzsub import sub_timezone
>>> sub_timezone('US-CA')
'America/Los_Angeles'
```

```python
>>> from pytzsub import all_code
>>> 'US-CA' in all_code()
True
```

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

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

It also works with [`pytz`](https://pypi.org/project/pytz/) if you prefer it:

```python
>>> 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

- Time Zone Database - [https://www.iana.org/time-zones][iana]
- ISO 3166-2 - <https://en.wikipedia.org/wiki/ISO_3166-2>

[iana]: https://www.iana.org/time-zones
[zoneinfo]: https://docs.python.org/3/library/zoneinfo.html
