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

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.1.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.1.0
File Size Uploaded
backports.zoneinfo-0.1.0.tar.gz 73.3 kB Details

Built distributions (wheels)

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

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

Download URL backports.zoneinfo-0.1.0.tar.gz
Size 73.3 kB
Tags Source
SHA-256 checksum
How to use checksums
9469dfb476b6b7af51980ece42a6671bdbf2a6e08a8fd947f83a19eb24765621
BLAKE2b-256 checksum
How to use checksums
522b9f93e4b8f20e9a1a2c8b6d33adbd961be534f83e874056c83dfa8cc9223b
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.0-cp38-cp38-win_amd64.whl

Download URL backports.zoneinfo-0.1.0-cp38-cp38-win_amd64.whl
Size 39.0 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
439f6922c94c62046d5dcacdea879be225446bd5bad5d7aa02b9010a91b270ff
BLAKE2b-256 checksum
How to use checksums
793f1d1a6d60933f1d95c545858ca5467af02398d3966976a4133df0284a00b3
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.0-cp38-cp38-win32.whl

Download URL backports.zoneinfo-0.1.0-cp38-cp38-win32.whl
Size 36.8 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
5034bf8ad6e9a45a6638d66bf457fd3a77e9a2beeb0f64661795eb542c8c50a2
BLAKE2b-256 checksum
How to use checksums
9791082d6cf39c0f1ca05ffda432c034b6e5c8edb5667949bbbf6a7bc359585f
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.0-cp38-cp38-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.1.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
10dd828980af7bc352d1a12e3c8334f3c504ac2b3e760b25ee082938e39d7909
BLAKE2b-256 checksum
How to use checksums
e5ebe942724e62dda2aea0d571b793c23ccad0774c863aa23a44f9fda0e35c44
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.0-cp38-cp38-manylinux1_i686.whl

Download URL backports.zoneinfo-0.1.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
2d556f6a75556a23ab5d545c73e09688bd035d21709822c9aaa0ccfaf8f0addc
BLAKE2b-256 checksum
How to use checksums
678d1032fe65341ee36ae2fa721b5d8e7f5fc4771cfb8bd60a42af8d6b79b1ff
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.0-cp38-cp38-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.1.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
7794b3b9d0b912f19f9ebfdfbaad18b6aa422f751089b5371f585194540a1a59
BLAKE2b-256 checksum
How to use checksums
2c0c3e5b3b09d1b52d251026539cea2fb5c4b16e3399e4d4c057064cd1a482a7
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.0-cp37-cp37m-win_amd64.whl

Download URL backports.zoneinfo-0.1.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
229d4d19c7144b59d2de444b070f334dc8c88f85d913fbb6980c21af720a89cc
BLAKE2b-256 checksum
How to use checksums
83cab92065cd09caf81738529eda05cca840594a7dba96db1c64dd1e64ad8773
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.0-cp37-cp37m-win32.whl

Download URL backports.zoneinfo-0.1.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
ce08c9be741b6549d0890b263549f032c8b7808c35797ba7139fea958a71f993
BLAKE2b-256 checksum
How to use checksums
656b73215f31b9f67565e0a81e35744a4ca127c991047e141f52fbadb75b8e30
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.0-cp37-cp37m-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.1.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
5422c5de4c06611e6269cacb621f8aa49260f97dbfdf50d121298cefd28c09c0
BLAKE2b-256 checksum
How to use checksums
cd9480be518a9b7ce854cde01d41e8bef06272acb3d46859a4f3085ba1af2b30
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.0-cp37-cp37m-manylinux1_i686.whl

Download URL backports.zoneinfo-0.1.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
b4352e43c0bc2f385d13ba3fc6d82373842159580d6b0866b41a6c01191d5b47
BLAKE2b-256 checksum
How to use checksums
9111f3cbd88ddc9d27db545751a0fd817f281da1b964da9ae66b5330b901933a
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.0-cp37-cp37m-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.1.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
fd6826eece351d73835834d2b3210b5575dc0a91da85c27082831e2089f59bd9
BLAKE2b-256 checksum
How to use checksums
73a9daf25fbfde82b49de5ba6ae197c166c73cd590775e7ac3a8f677a9a53cd4
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.0-cp36-cp36m-win_amd64.whl

Download URL backports.zoneinfo-0.1.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
f5aad97982c2cf46d58bf56d3a962c63788e0efb7cbeb9d269f7d00f5ebc28dc
BLAKE2b-256 checksum
How to use checksums
7c16ab3dca2df937945713bde03980c79ce9a3fc87177673ab41d9c4fdd5af01
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.0-cp36-cp36m-win32.whl

Download URL backports.zoneinfo-0.1.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
f85331838325ac195e3d43d9178b947f445a837196b4edf1348dfa4275d153e0
BLAKE2b-256 checksum
How to use checksums
5723db1970947639d0feb6aa67a1c5df173743a6c92141371c63cb91760b717f
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.0-cp36-cp36m-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.1.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
82b4892ee67162604eea9291e0c052a7a1c40da55aadc8379659f985161bfa3c
BLAKE2b-256 checksum
How to use checksums
2d77b04235e2b61abb27ee53a880ca24ed6317e6c3be19ceadbf549b7b7c89e3
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.0-cp36-cp36m-manylinux1_i686.whl

Download URL backports.zoneinfo-0.1.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
9fde6dba3e0aa0c9d253f0074467cdf0961604c00cd3ac465234d93973483290
BLAKE2b-256 checksum
How to use checksums
b23700c95b41640ca2203fe9943536235729e112d495ec274f641f258e1bdacd
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.0-cp36-cp36m-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.1.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
cf08add78491b59b7bc2cb1e4f5f6f763e669081ed125e4e4f42d9751670230d
BLAKE2b-256 checksum
How to use checksums
93b78bb7e9cac66b43549ea5d9fd850a554e3c308670daa60371d486b1e6ea35
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

This release

0.1.0 This release

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