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.

Metadata

Release files for backports.zoneinfo 0.2.0

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.0
File Size Uploaded
backports.zoneinfo-0.2.0.tar.gz 73.6 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for backports.zoneinfo 0.2.0
File
backports.zoneinfo-0.2.0-cp38-cp38-win_amd64.whl CPython 3.8 CPython 3.8 Windows x86-64 Details
backports.zoneinfo-0.2.0-cp38-cp38-win32.whl CPython 3.8 CPython 3.8 Windows x86-32 Details
backports.zoneinfo-0.2.0-cp38-cp38-manylinux1_x86_64.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-64 Details
backports.zoneinfo-0.2.0-cp38-cp38-manylinux1_i686.whl CPython 3.8 CPython 3.8 Linux glibc 2.5+ x86-32 Details
backports.zoneinfo-0.2.0-cp38-cp38-macosx_10_14_x86_64.whl CPython 3.8 CPython 3.8 macOS 10.14+ x86-64 Details
backports.zoneinfo-0.2.0-cp37-cp37m-win_amd64.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-64 Details
backports.zoneinfo-0.2.0-cp37-cp37m-win32.whl CPython 3.7 CPython 3.7 pymalloc Windows x86-32 Details
backports.zoneinfo-0.2.0-cp37-cp37m-manylinux1_x86_64.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-64 Details
backports.zoneinfo-0.2.0-cp37-cp37m-manylinux1_i686.whl CPython 3.7 CPython 3.7 pymalloc Linux glibc 2.5+ x86-32 Details
backports.zoneinfo-0.2.0-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.0-cp36-cp36m-win_amd64.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-64 Details
backports.zoneinfo-0.2.0-cp36-cp36m-win32.whl CPython 3.6 CPython 3.6 pymalloc Windows x86-32 Details
backports.zoneinfo-0.2.0-cp36-cp36m-manylinux1_x86_64.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-64 Details
backports.zoneinfo-0.2.0-cp36-cp36m-manylinux1_i686.whl CPython 3.6 CPython 3.6 pymalloc Linux glibc 2.5+ x86-32 Details
backports.zoneinfo-0.2.0-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.2 kB

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

Download URL backports.zoneinfo-0.2.0.tar.gz
Size 73.6 kB
Tags Source
SHA-256 checksum
How to use checksums
23b39f0a0ab4a640091ec7c20846e7d90bda98f88e6117e5f417c2b0a5564590
BLAKE2b-256 checksum
How to use checksums
cbc0158dd4a82e43b0216f8fb050b6779726294302d79e9d56ff6b6588d07022
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.2.0-cp38-cp38-win_amd64.whl

Download URL backports.zoneinfo-0.2.0-cp38-cp38-win_amd64.whl
Size 39.0 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
658a4e4f2e9a2fd9b870b7301a281ab4831f67845df1e4c1022df39396e81827
BLAKE2b-256 checksum
How to use checksums
f2e90012a1f35b4a1b4d8ff101b76cb9f40bcca5bdd3710a2ecf3c129cdd2c1a
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.2.0-cp38-cp38-win32.whl

Download URL backports.zoneinfo-0.2.0-cp38-cp38-win32.whl
Size 36.8 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
d48572dca821325c7febc25efd7d7da59e4c7ea84925cc0c3cd10527fde50e20
BLAKE2b-256 checksum
How to use checksums
9f3a49c360ab98752f9f653079859e022e6c60f88226c910ec0608ee8f3ad10a
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.2.0-cp38-cp38-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.2.0-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
d7bc29e9c524e948e1201674c6c8fa71cf3d0eb79d0b7117d96967e3a7447cb9
BLAKE2b-256 checksum
How to use checksums
5d017c473917e1c705a471296b94dfe742f33cb196fa94946cfb4fd304f2f635
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.2.0-cp38-cp38-manylinux1_i686.whl

Download URL backports.zoneinfo-0.2.0-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
ca4ff0229810329eeaee954fb0422794a145d00cb8cdf6f259d89f835fdc9c13
BLAKE2b-256 checksum
How to use checksums
c7fc40828234ebb09f7e163795dba39c3b392f7e388317fd2a1e0df6ae284068
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.2.0-cp38-cp38-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.2.0-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
728085c09decc8e25ecd67d5601de3231171cf8569a1b464e3748419d07fcd8e
BLAKE2b-256 checksum
How to use checksums
6c413c4db99a9c7ee146d0bb05998dac932d39d4ab0fe0384eab5c4274f043cd
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.2.0-cp37-cp37m-win_amd64.whl

Download URL backports.zoneinfo-0.2.0-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
551e71f3be794b45d4070f56d0a422d58a86d498d18862bccadaa1e6061511f2
BLAKE2b-256 checksum
How to use checksums
5033dbae9c84cc093c5137a3481a6b926698e583b0512b8167987ed0f465e98f
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.2.0-cp37-cp37m-win32.whl

Download URL backports.zoneinfo-0.2.0-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
5c1f686557341ffe53cce331b40f4e5a7388ddbb1a6324261070a3b490db5dc9
BLAKE2b-256 checksum
How to use checksums
f041c0716b5a21e77b2a7961a8e88b40fddb6377eaa68fe3b2c8384e99c2e4c3
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.2.0-cp37-cp37m-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.2.0-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
c8e5d61dd9d130e853aa7a9fc23cd3e4b5a98e7bf4a3b8cefb68afd37bf0160b
BLAKE2b-256 checksum
How to use checksums
779f65eef4b040a98470c01f0126594ec8c17067a22387c03a841cb5c2a950fa
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.2.0-cp37-cp37m-manylinux1_i686.whl

Download URL backports.zoneinfo-0.2.0-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
c28b0e13275682c61844ba30835b6b59986e31c59f1176506416d85dbdb6d199
BLAKE2b-256 checksum
How to use checksums
3af4324a0b66827c4711474a0ab420fbd32b3e5775f261e91a124b50e89c249c
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.2.0-cp37-cp37m-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.2.0-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
4596f7d2b6ded0525359bdf4d8940128c0c840e762728f8ee4efc8cbc5a8aa53
BLAKE2b-256 checksum
How to use checksums
687aff0e6c1adc0daca0a2fbd1f12c16ab43eb7750547d83af0850ba1317da0b
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.2.0-cp36-cp36m-win_amd64.whl

Download URL backports.zoneinfo-0.2.0-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
f778bf7b8210970ff8fea9060eea452dc3747fa0a79f81fa33708c6b9a043ef2
BLAKE2b-256 checksum
How to use checksums
6f3db8d87841c15209222e6f4b98c25c51a2298daa4aeea30b67d70f76c1a198
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.2.0-cp36-cp36m-win32.whl

Download URL backports.zoneinfo-0.2.0-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
ea3ecb3f816e4bac96e0562660340cc1e063ae5bb04f7128af69c2d83019ccb2
BLAKE2b-256 checksum
How to use checksums
127f62d9ce246fdb23ebca98096d9a757306b63676d3baf1eda0c4548dcadf20
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.2.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.2.0-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
ff638c552cf342a31cb8bdb7e4e4c1fcac61d01c23e109f72e11a23631107765
BLAKE2b-256 checksum
How to use checksums
8d4df84074bc450761ceef7bd8efc5c6935ae665a87dbc423c3e98ac56e2c35a
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.2.0-cp36-cp36m-manylinux1_i686.whl

Download URL backports.zoneinfo-0.2.0-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
7cdedc966a61cdaf1a7069468f9a0208b35a7eb90135a989c9ec9e4fe771d89d
BLAKE2b-256 checksum
How to use checksums
0a78b67627ef75dd6281ca57bb6596bd9eb6afe935c4fbeb6d53420e6d016232
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.2.0-cp36-cp36m-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.2.0-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
46e99bcc81476e3f6f430b78a4485fb6d0fab2ce2ab6f1c4de8ba1d89469b029
BLAKE2b-256 checksum
How to use checksums
6fec0a815c58e4d2b2af371ba5df89931b5b0e8835329149e809edf3a92be8a6
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

This release

0.2.0 This release

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