Skip to main content

Backport of the standard library zoneinfo module

Project description

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

backports.zoneinfo-0.2.1.tar.gz (74.1 kB view details)

Uploaded Source

Built Distributions

backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl (39.0 kB view details)

Uploaded CPython 3.8 Windows x86-64

backports.zoneinfo-0.2.1-cp38-cp38-win32.whl (36.8 kB view details)

Uploaded CPython 3.8 Windows x86

backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl (35.8 kB view details)

Uploaded CPython 3.8 macOS 10.14+ x86-64

backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl (38.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl (36.5 kB view details)

Uploaded CPython 3.7m Windows x86

backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl (69.0 kB view details)

Uploaded CPython 3.7m

backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl (35.6 kB view details)

Uploaded CPython 3.7m macOS 10.14+ x86-64

backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl (38.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl (36.5 kB view details)

Uploaded CPython 3.6m Windows x86

backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl (68.8 kB view details)

Uploaded CPython 3.6m

backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl (35.6 kB view details)

Uploaded CPython 3.6m macOS 10.14+ x86-64

File details

Details for the file backports.zoneinfo-0.2.1.tar.gz.

File metadata

  • Download URL: backports.zoneinfo-0.2.1.tar.gz
  • Upload date:
  • Size: 74.1 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1.tar.gz
Algorithm Hash digest
SHA256 fadbfe37f74051d024037f223b8e001611eac868b5c5b06144ef4d8b799862f2
MD5 d51faaaed4a1d5158dcfcef90355e805
BLAKE2b-256 ad85475e514c3140937cf435954f78dedea1861aeab7662d11de232bdaa90655

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl
  • Upload date:
  • Size: 39.0 kB
  • Tags: CPython 3.8, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 4a0f800587060bf8880f954dbef70de6c11bbe59c673c3d818921f042f9954a6
MD5 6d655f37507c41ff543568c2c40b260a
BLAKE2b-256 78cce27fd6493bbce8dbea7e6c1bc861fe3d3bc22c4f7c81f4c3befb8ff5bfaf

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp38-cp38-win32.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp38-cp38-win32.whl
  • Upload date:
  • Size: 36.8 kB
  • Tags: CPython 3.8, Windows x86
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 1b13e654a55cd45672cb54ed12148cd33628f672548f373963b0bff67b217328
MD5 5bebebf7a794cf050f9aa126256acaf6
BLAKE2b-256 c0345fdb0a3a28841d215c255be8fc60b8666257bb6632193c86fd04b63d4a31

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl
  • Upload date:
  • Size: 74.0 kB
  • Tags: CPython 3.8
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 7b0a64cda4145548fed9efc10322770f929b944ce5cee6c0dfe0c87bf4c0c8c9
MD5 4dc541b06ff98020b5c5f35f4cb18a76
BLAKE2b-256 1aab3e941e3fcf1b7d3ab3d0233194d99d6a0ed6b24f8f956fc81e47edc8c079

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_i686.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_i686.whl
  • Upload date:
  • Size: 72.1 kB
  • Tags: CPython 3.8
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 e81b76cace8eda1fca50e345242ba977f9be6ae3945af8d46326d776b4cf78d1
MD5 81c0481b333c5f28306c9c455d34155e
BLAKE2b-256 c18f9b1b920a6a95652463143943fa3b8c000cb0b932ab463764a6f2a2416560

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 35.8 kB
  • Tags: CPython 3.8, macOS 10.14+ x86-64
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 8961c0f32cd0336fb8e8ead11a1f8cd99ec07145ec2931122faaac1c8f7fd987
MD5 ab6946fc5ca129694a8ee87f8d415e8b
BLAKE2b-256 4a6deca004eeadcbf8bd64cc96feb9e355536147f0577420b44d80c7cac70767

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: CPython 3.7m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 a76b38c52400b762e48131494ba26be363491ac4f9a04c1b7e92483d169f6582
MD5 8b69f227dd1665ecd5b32b4715d9bad1
BLAKE2b-256 6c99513f2c4dd41522eefc42feb86854f6cf3b1add9c175c14d90c070775e484

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: CPython 3.7m, Windows x86
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 e55b384612d93be96506932a786bbcde5a2db7a9e6a4bb4bffe8b733f5b9036b
MD5 b47fb1a85356ad96c9887254a8c6b93a
BLAKE2b-256 1c96baaca3ad1b06d97138d42a225e4d4d27cd1586b646740f771706cd2d812c

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 70.7 kB
  • Tags: CPython 3.7m
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5c144945a7752ca544b4b78c8c41544cdfaf9786f25fe5ffb10e838e19a27570
MD5 5ff0350d40a18d7a23663ca7ae2fe4f6
BLAKE2b-256 4c7eed8af95bed90eeccfb4a4fe6ec424bc7a79e1aa983e54dd1d9062d9fa20b

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl
  • Upload date:
  • Size: 69.0 kB
  • Tags: CPython 3.7m
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 17746bd546106fa389c51dbea67c8b7c8f0d14b5526a579ca6ccf5ed72c526cf
MD5 e31b39ae295a453444b63ec2d209e12a
BLAKE2b-256 d1048f2fed9c0cb9c88442fc8d6372cb0f5738fb05a65b45e2d371fbc8a15087

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: CPython 3.7m, macOS 10.14+ x86-64
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 f04e857b59d9d1ccc39ce2da1021d196e47234873820cbeaad210724b1ee28ac
MD5 23b3f52821598e5c4d93ced1f895388c
BLAKE2b-256 74a1323f86a5ca5a559d452affb879512365a0473529398bfcf2d712a40ae088

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl
  • Upload date:
  • Size: 38.7 kB
  • Tags: CPython 3.6m, Windows x86-64
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 8439c030a11780786a2002261569bdf362264f605dfa4d65090b64b05c9f79a7
MD5 c4bd76ec1fbae469faa04853ad616b1d
BLAKE2b-256 28d5e2f3d6a52870045afd8c37b2681c47fd0b98679cd4851e349bfd7e19cfd7

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl
  • Upload date:
  • Size: 36.5 kB
  • Tags: CPython 3.6m, Windows x86
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 e8236383a20872c0cdf5a62b554b27538db7fa1bbec52429d8d106effbaeca08
MD5 4b0a671eaaccd979e2789f601bde1c78
BLAKE2b-256 d479249bd3c4f794741f04f1e0ff33ad3cca9b2d1f4299b73f78d0d9bc9ec8dc

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_x86_64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_x86_64.whl
  • Upload date:
  • Size: 70.7 kB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 1c5742112073a563c81f786e77514969acb58649bcdf6cdf0b4ed31a348d4546
MD5 84b4cf54659da37db04d82828da59406
BLAKE2b-256 f90433e910faffe91a5680d68a064162525779259ae5de3b0c0c5bd9c4e900e0

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl
  • Upload date:
  • Size: 68.8 kB
  • Tags: CPython 3.6m
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 89a48c0d158a3cc3f654da4c2de1ceba85263fafb861b98b59040a5086259722
MD5 7ab9b8939f3c554bb6ab5b97fe12eed7
BLAKE2b-256 ef9a8de8f379d5b3961a517762cc051b366de3f7d4d3a2250120e7a71e25fab4

See more details on using hashes here.

File details

Details for the file backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl.

File metadata

  • Download URL: backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl
  • Upload date:
  • Size: 35.6 kB
  • Tags: CPython 3.6m, macOS 10.14+ x86-64
  • Uploaded using 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

File hashes

Hashes for backports.zoneinfo-0.2.1-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 da6013fd84a690242c310d77ddb8441a559e9cb3d3d59ebac9aca1a57b2e18bc
MD5 996b2685962e70970bad27892e61e543
BLAKE2b-256 331c9357061860f5d3a09e1877aa4cf7c004c55eec40a1036761144ef24d8a1d

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page