Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

backports.zoneinfo: Backport of the standard library module zoneinfo

This package was originally the reference implementation for PEP 615, which proposes support for the IANA time zone database in the standard library, and now serves as a backport to Python 3.7+.

This exposes the backports.zoneinfo module, which is a backport of the zoneinfo module. The backport's documentation can be found on readthedocs.

The module uses the system time zone data if available, and falls back to the tzdata package (available on PyPI) if installed.

Installation and depending on this library

This module is called backports.zoneinfo on PyPI. To install it in your local environment, use:

pip install backports.zoneinfo

Or (particularly on Windows), you can also use the tzdata extra (which basically just declares a dependency on tzdata, so this doesn't actually save you any typing 😅):

pip install backports.zoneinfo[tzdata]

If you want to use this in your application, it is best to use PEP 508 environment markers to declare a dependency conditional on the Python version:

backports.zoneinfo;python_version<"3.9"

Support for backports.zoneinfo in Python 3.9+ is currently minimal, since it is expected that you would use the standard library zoneinfo module instead.

Use

The backports.zoneinfo module should be a drop-in replacement for the Python 3.9 standard library module zoneinfo. If you do not support anything earlier than Python 3.9, you do not need this library; if you are supporting Python 3.7+, you may want to use this idiom to "fall back" to backports.zoneinfo:

try:
    import zoneinfo
except ImportError:
    from backports import zoneinfo

To get access to time zones with this module, construct a ZoneInfo object and attach it to your datetime:

>>> from backports.zoneinfo import ZoneInfo
>>> from datetime import datetime, timedelta, timezone
>>> dt = datetime(1992, 3, 1, tzinfo=ZoneInfo("Europe/Minsk"))
>>> print(dt)
1992-03-01 00:00:00+02:00
>>> print(dt.utcoffset())
2:00:00
>>> print(dt.tzname())
EET

Arithmetic works as expected without the need for a "normalization" step:

>>> dt += timedelta(days=90)
>>> print(dt)
1992-05-30 00:00:00+03:00
>>> dt.utcoffset()
datetime.timedelta(seconds=10800)
>>> dt.tzname()
'EEST'

Ambiguous and imaginary times are handled using the fold attribute added in PEP 495:

>>> dt = datetime(2020, 11, 1, 1, tzinfo=ZoneInfo("America/Chicago"))
>>> print(dt)
2020-11-01 01:00:00-05:00
>>> print(dt.replace(fold=1))
2020-11-01 01:00:00-06:00

>>> UTC = timezone.utc
>>> print(dt.astimezone(UTC))
2020-11-01 06:00:00+00:00
>>> print(dt.replace(fold=1).astimezone(UTC))
2020-11-01 07:00:00+00:00

Contributing

Currently we are not accepting contributions to this repository because we have not put the CLA in place and we would like to avoid complicating the process of adoption into the standard library. Contributions to CPython will eventually be backported to this repository — see the Python developer's guide for more information on how to contribute to CPython.

Metadata

Release files for backports.zoneinfo 0.1.0b1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for backports.zoneinfo 0.1.0b1
File Size Uploaded
backports.zoneinfo-0.1.0b1.tar.gz 72.1 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for backports.zoneinfo 0.1.0b1
File
backports.zoneinfo-0.1.0b1-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
backports.zoneinfo-0.1.0b1-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
backports.zoneinfo-0.1.0b1-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
backports.zoneinfo-0.1.0b1-cp38-cp38-manylinux1_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-32 Details
backports.zoneinfo-0.1.0b1-cp38-cp38-macosx_10_14_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.14+ x86-64 Details
backports.zoneinfo-0.1.0b1-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
backports.zoneinfo-0.1.0b1-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
backports.zoneinfo-0.1.0b1-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
backports.zoneinfo-0.1.0b1-cp37-cp37m-manylinux1_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32 Details
backports.zoneinfo-0.1.0b1-cp37-cp37m-macosx_10_14_x86_64.whl CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64 Details

Total release size: 576.8 kB

Release files / backports.zoneinfo-0.1.0b1.tar.gz

Download URL backports.zoneinfo-0.1.0b1.tar.gz
Size 72.1 kB
Tags Source
SHA-256 checksum
How to use checksums
aca81b6bca379f5764c117598ac11d894f7ca1977749375e178763bbbb30e765
BLAKE2b-256 checksum
How to use checksums
522d4c6a9436cb38c1812bf1d75afb4d395ffbb3fbfba9cd8898704dc88b7e39
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp38-cp38-win_amd64.whl

Download URL backports.zoneinfo-0.1.0b1-cp38-cp38-win_amd64.whl
Size 38.6 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
6484e89e3894c4c1ab76a667f90da6816f3efeedd5961ef6b7242c486b52d89b
BLAKE2b-256 checksum
How to use checksums
f372227d9361261c06a6919ea0749d0dc4eb72a6c73099db65b82e960ff07cfd
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp38-cp38-win32.whl

Download URL backports.zoneinfo-0.1.0b1-cp38-cp38-win32.whl
Size 36.5 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
8e0080b792a2ab274823ecb868662f67b056a0fcf606b26fce5c6f5da4e1cc0c
BLAKE2b-256 checksum
How to use checksums
f5234927c4343c7fe5b99391c5f307601dc53ceff2b7b810874ec397ce6a6ef4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp38-cp38-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.1.0b1-cp38-cp38-manylinux1_x86_64.whl
Size 73.5 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
3c41f4b5ec304bbcdd3bf7b731ec1fbb07ddf78a50262576f46ec77f00027fde
BLAKE2b-256 checksum
How to use checksums
f9eb229a990345477aa042065c73663c108e293353f8b9d94c941dbed36241de
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp38-cp38-manylinux1_i686.whl

Download URL backports.zoneinfo-0.1.0b1-cp38-cp38-manylinux1_i686.whl
Size 71.6 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
97972ec8d7b509eb9d2d5c9ff005aebbe0e8c6a50ef4700a6498d79a9af65ba4
BLAKE2b-256 checksum
How to use checksums
15aa99691fa459991fcb5f98ced2e0b2dcfca94f5011ebf295c86256cad0d328
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp38-cp38-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.1.0b1-cp38-cp38-macosx_10_14_x86_64.whl
Size 35.6 kB
Tags CPython 3.8 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
0d57ef70af693b7258ee63d409d0f452a4d07357643ebc9f728f68384cd4864b
BLAKE2b-256 checksum
How to use checksums
8ce733ed12e09448832f0929f2131435ea2577e31db3b1e5c65efa67fb3deec7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp37-cp37m-win_amd64.whl

Download URL backports.zoneinfo-0.1.0b1-cp37-cp37m-win_amd64.whl
Size 38.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
32c3b8c5614c874bdd5b3ea5e0a35ad65bf8fc73420967bfe3c3fb76d4596db1
BLAKE2b-256 checksum
How to use checksums
f3e86011ee0c0274c681a50fe84e3ab7ba5e03915d000b3c09ec63fb217eb7b5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp37-cp37m-win32.whl

Download URL backports.zoneinfo-0.1.0b1-cp37-cp37m-win32.whl
Size 36.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
5bbc89eade453c396cbe929e21a472768736529616b188694bd6ad83f3e3e5d4
BLAKE2b-256 checksum
How to use checksums
f008eab799f8b740cff6947c7d1268e38bb00b0a6ce0d0770d127e39284a725a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp37-cp37m-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.1.0b1-cp37-cp37m-manylinux1_x86_64.whl
Size 70.2 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
9124a2a8baab4e0267659bf2062fefbe3cce365d8324e77daaae6e2cb52c81dc
BLAKE2b-256 checksum
How to use checksums
4590e2bcf9161a297dacda20b3f21f5cbec715393fac38f918db10729adc7d3b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp37-cp37m-manylinux1_i686.whl

Download URL backports.zoneinfo-0.1.0b1-cp37-cp37m-manylinux1_i686.whl
Size 68.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
a4928d86336623d36d2dee60cbef8c5f5e2bd3542037096a858b6764d6703d62
BLAKE2b-256 checksum
How to use checksums
a2e29aa2f461a2decd60d41041faa18d4cb140fd2b667e8573cf1fe839286b51
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release files / backports.zoneinfo-0.1.0b1-cp37-cp37m-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.1.0b1-cp37-cp37m-macosx_10_14_x86_64.whl
Size 35.4 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
793aa1635276e9b295ad0314ad02b8aed7cd1e233a94660c45c6de6f2fb099bb
BLAKE2b-256 checksum
How to use checksums
b74f198b43f767c000c6cf678cea24f93581de16ae09aa380552c1952bf1ab8f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.4.0 requests-toolbelt/0.9.1 tqdm/4.46.0 CPython/3.8.3

Release history Release notifications | RSS feed

0.2.1

16 release files

0.2.0

16 release files

0.1.0

16 release files

This release

0.1.0b1 This release

11 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page