Skip to main content

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.6+ (including PyPy).

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.6+, 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.

Release files for backports.zoneinfo 0.2.1

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.2.1
File Size Uploaded
backports.zoneinfo-0.2.1.tar.gz 74.1 kB Details

Built distributions (wheels)

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

Total release size: 832.7 kB

Release files / backports.zoneinfo-0.2.1.tar.gz

Download URL backports.zoneinfo-0.2.1.tar.gz
Size 74.1 kB
Tags Source
SHA-256 checksum
How to use checksums
fadbfe37f74051d024037f223b8e001611eac868b5c5b06144ef4d8b799862f2
BLAKE2b-256 checksum
How to use checksums
ad85475e514c3140937cf435954f78dedea1861aeab7662d11de232bdaa90655
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl

Download URL backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl
Size 39.0 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
4a0f800587060bf8880f954dbef70de6c11bbe59c673c3d818921f042f9954a6
BLAKE2b-256 checksum
How to use checksums
78cce27fd6493bbce8dbea7e6c1bc861fe3d3bc22c4f7c81f4c3befb8ff5bfaf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp38-cp38-win32.whl

Download URL backports.zoneinfo-0.2.1-cp38-cp38-win32.whl
Size 36.8 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328
BLAKE2b-256 checksum
How to use checksums
c0345fdb0a3a28841d215c255be8fc60b8666257bb6632193c86fd04b63d4a31
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl
Size 74.0 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9
BLAKE2b-256 checksum
How to use checksums
1aab3e941e3fcf1b7d3ab3d0233194d99d6a0ed6b24f8f956fc81e47edc8c079
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_i686.whl

Download URL backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_i686.whl
Size 72.1 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
e81b76cace8eda1fca50e345242ba977f9be6ae3945af8d46326d776b4cf78d1
BLAKE2b-256 checksum
How to use checksums
c18f9b1b920a6a95652463143943fa3b8c000cb0b932ab463764a6f2a2416560
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl
Size 35.8 kB
Tags CPython 3.8 macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
8961c0f32cd0336fb8e8ead11a1f8cd99ec07145ec2931122faaac1c8f7fd987
BLAKE2b-256 checksum
How to use checksums
4a6deca004eeadcbf8bd64cc96feb9e355536147f0577420b44d80c7cac70767
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl

Download URL backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl
Size 38.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
a76b38c52400b762e48131494ba26be363491ac4f9a04c1b7e92483d169f6582
BLAKE2b-256 checksum
How to use checksums
6c99513f2c4dd41522eefc42feb86854f6cf3b1add9c175c14d90c070775e484
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl

Download URL backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl
Size 36.5 kB
Tags CPython 3.7 CPython 3.7 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e55b384612d93be96506932a786bbcde5a2db7a9e6a4bb4bffe8b733f5b9036b
BLAKE2b-256 checksum
How to use checksums
1c96baaca3ad1b06d97138d42a225e4d4d27cd1586b646740f771706cd2d812c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl
Size 70.7 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
5c144945a7752ca544b4b78c8c41544cdfaf9786f25fe5ffb10e838e19a27570
BLAKE2b-256 checksum
How to use checksums
4c7eed8af95bed90eeccfb4a4fe6ec424bc7a79e1aa983e54dd1d9062d9fa20b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl

Download URL backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl
Size 69.0 kB
Tags CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf
BLAKE2b-256 checksum
How to use checksums
d1048f2fed9c0cb9c88442fc8d6372cb0f5738fb05a65b45e2d371fbc8a15087
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl
Size 35.6 kB
Tags CPython 3.7 CPython 3.7 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
f04e857b59d9d1ccc39ce2da1021d196e47234873820cbeaad210724b1ee28ac
BLAKE2b-256 checksum
How to use checksums
74a1323f86a5ca5a559d452affb879512365a0473529398bfcf2d712a40ae088
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl

Download URL backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl
Size 38.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-64
SHA-256 checksum
How to use checksums
8439c030a11780786a2002261569bdf362264f605dfa4d65090b64b05c9f79a7
BLAKE2b-256 checksum
How to use checksums
28d5e2f3d6a52870045afd8c37b2681c47fd0b98679cd4851e349bfd7e19cfd7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl

Download URL backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl
Size 36.5 kB
Tags CPython 3.6 CPython 3.6 pymalloc Windows x86-32
SHA-256 checksum
How to use checksums
e8236383a20872c0cdf5a62b554b27538db7fa1bbec52429d8d106effbaeca08
BLAKE2b-256 checksum
How to use checksums
d479249bd3c4f794741f04f1e0ff33ad3cca9b2d1f4299b73f78d0d9bc9ec8dc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_x86_64.whl
Size 70.7 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
1c5742112073a563c81f786e77514969acb58649bcdf6cdf0b4ed31a348d4546
BLAKE2b-256 checksum
How to use checksums
f90433e910faffe91a5680d68a064162525779259ae5de3b0c0c5bd9c4e900e0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl

Download URL backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl
Size 68.8 kB
Tags CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
89a48c0d158a3cc3f654da4c2de1ceba85263fafb861b98b59040a5086259722
BLAKE2b-256 checksum
How to use checksums
ef9a8de8f379d5b3961a517762cc051b366de3f7d4d3a2250120e7a71e25fab4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release files / backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl
Size 35.6 kB
Tags CPython 3.6 CPython 3.6 pymalloc macOS 10.14+ x86-64
SHA-256 checksum
How to use checksums
da6013fd84a690242c310d77ddb8441a559e9cb3d3d59ebac9aca1a57b2e18bc
BLAKE2b-256 checksum
How to use checksums
331c9357061860f5d3a09e1877aa4cf7c004c55eec40a1036761144ef24d8a1d
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0rc1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.8.3

Release history Release notifications | RSS feed

This release

0.2.1 This release

16 release files

0.2.0

16 release files

0.1.0

16 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