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

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.8+, 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.0b0

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.0b0
File Size Uploaded
backports.zoneinfo-0.1.0b0.tar.gz 71.8 kB Details

Built distributions (wheels)

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

Total release size: 327.1 kB

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

Download URL backports.zoneinfo-0.1.0b0.tar.gz
Size 71.8 kB
Tags Source
SHA-256 checksum
How to use checksums
3f9f771b601a31e86233851acc2989bd14b3b57791f1d985b369f73cb0e15608
BLAKE2b-256 checksum
How to use checksums
bb8db5e3e2da72f7fa687643766d52cfebdab3402bc165a25247f97a9bfba04b
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.0b0-cp38-cp38-win_amd64.whl

Download URL backports.zoneinfo-0.1.0b0-cp38-cp38-win_amd64.whl
Size 38.5 kB
Tags CPython 3.8 Windows x86-64
SHA-256 checksum
How to use checksums
c84af3bf7d9fd84704979d4f0ef7aacc34f0d5409ec26345dd2240bd7096e3d6
BLAKE2b-256 checksum
How to use checksums
cee4ab0ecce13eb55e7f735ef83cfc5cebcf8905d85b493a2b89fea1bc523462
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.0b0-cp38-cp38-win32.whl

Download URL backports.zoneinfo-0.1.0b0-cp38-cp38-win32.whl
Size 36.4 kB
Tags CPython 3.8 Windows x86-32
SHA-256 checksum
How to use checksums
7b2e3c71605683b8334428690db85cdd03ba35843bd762735c0188ffc231f250
BLAKE2b-256 checksum
How to use checksums
4f765dabc00b964790b325013a2dc1e4e9aab8c5d28ea052bb27649497a7ff44
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.0b0-cp38-cp38-manylinux1_x86_64.whl

Download URL backports.zoneinfo-0.1.0b0-cp38-cp38-manylinux1_x86_64.whl
Size 73.4 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-64
SHA-256 checksum
How to use checksums
9da738644c350232cb2f43dc16f4e2dadc6d814dc4aafbffe376147ad4a4a536
BLAKE2b-256 checksum
How to use checksums
fb6a7069603f9a99ccc6a734391433f650db17748231a7e2c130344ba48483fb
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.0b0-cp38-cp38-manylinux1_i686.whl

Download URL backports.zoneinfo-0.1.0b0-cp38-cp38-manylinux1_i686.whl
Size 71.5 kB
Tags CPython 3.8 Linux glibc 2.5+ x86-32
SHA-256 checksum
How to use checksums
38291a5c1a20601ad934d7e9de032a52ae0d8b93031224e5fbc2da28884178a6
BLAKE2b-256 checksum
How to use checksums
ac02a845408168bc800845c0bf47ac7f269f443c85dfd47f2cf70af8c0d2a731
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.0b0-cp38-cp38-macosx_10_14_x86_64.whl

Download URL backports.zoneinfo-0.1.0b0-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
87890d65150fd7a5bde63e3d5ec2a8e1cd0b943825997c562c9a394ef020899d
BLAKE2b-256 checksum
How to use checksums
038940c8ff853e520d2d140b2b5b69264306e01fac655376520b2cd09ac53d07
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.0b0 This release

6 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