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

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.1.0.tar.gz (73.3 kB view details)

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 Windows x86

backports.zoneinfo-0.1.0-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.1.0-cp37-cp37m-win_amd64.whl (38.7 kB view details)

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m Windows x86

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

Uploaded CPython 3.7m

backports.zoneinfo-0.1.0-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.1.0-cp36-cp36m-win_amd64.whl (38.7 kB view details)

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m Windows x86

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

Uploaded CPython 3.6m

backports.zoneinfo-0.1.0-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.1.0.tar.gz.

File metadata

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

File hashes

Hashes for backports.zoneinfo-0.1.0.tar.gz
Algorithm Hash digest
SHA256 9469dfb476b6b7af51980ece42a6671bdbf2a6e08a8fd947f83a19eb24765621
MD5 fffddcd86ec554718d73d6588cea86b7
BLAKE2b-256 522b9f93e4b8f20e9a1a2c8b6d33adbd961be534f83e874056c83dfa8cc9223b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 439f6922c94c62046d5dcacdea879be225446bd5bad5d7aa02b9010a91b270ff
MD5 231b450cbd1720714261e3e19f3dfc8a
BLAKE2b-256 793f1d1a6d60933f1d95c545858ca5467af02398d3966976a4133df0284a00b3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 5034bf8ad6e9a45a6638d66bf457fd3a77e9a2beeb0f64661795eb542c8c50a2
MD5 98329a70aebde8e08f8305a90b638c01
BLAKE2b-256 9791082d6cf39c0f1ca05ffda432c034b6e5c8edb5667949bbbf6a7bc359585f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 10dd828980af7bc352d1a12e3c8334f3c504ac2b3e760b25ee082938e39d7909
MD5 ac3aed47028652c33815bda879691b96
BLAKE2b-256 e5ebe942724e62dda2aea0d571b793c23ccad0774c863aa23a44f9fda0e35c44

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 2d556f6a75556a23ab5d545c73e09688bd035d21709822c9aaa0ccfaf8f0addc
MD5 ac20cd39e357b888efead58e5a8ea0b2
BLAKE2b-256 678d1032fe65341ee36ae2fa721b5d8e7f5fc4771cfb8bd60a42af8d6b79b1ff

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 7794b3b9d0b912f19f9ebfdfbaad18b6aa422f751089b5371f585194540a1a59
MD5 363cd4dff6e5848a3de60ea1a0f14ec1
BLAKE2b-256 2c0c3e5b3b09d1b52d251026539cea2fb5c4b16e3399e4d4c057064cd1a482a7

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 229d4d19c7144b59d2de444b070f334dc8c88f85d913fbb6980c21af720a89cc
MD5 c5b9e2420f8a932b7a1a4a95f1bb1c5b
BLAKE2b-256 83cab92065cd09caf81738529eda05cca840594a7dba96db1c64dd1e64ad8773

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 ce08c9be741b6549d0890b263549f032c8b7808c35797ba7139fea958a71f993
MD5 a4934a012676da5fa7a8cf2f86989e39
BLAKE2b-256 656b73215f31b9f67565e0a81e35744a4ca127c991047e141f52fbadb75b8e30

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 5422c5de4c06611e6269cacb621f8aa49260f97dbfdf50d121298cefd28c09c0
MD5 3f7cab0f0be42d99c9eb79940b25114b
BLAKE2b-256 cd9480be518a9b7ce854cde01d41e8bef06272acb3d46859a4f3085ba1af2b30

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 b4352e43c0bc2f385d13ba3fc6d82373842159580d6b0866b41a6c01191d5b47
MD5 40582ca2b1d19495517aaeff60879ea1
BLAKE2b-256 9111f3cbd88ddc9d27db545751a0fd817f281da1b964da9ae66b5330b901933a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 fd6826eece351d73835834d2b3210b5575dc0a91da85c27082831e2089f59bd9
MD5 6c89e9ace0dd4bf84645b5056ff0428b
BLAKE2b-256 73a9daf25fbfde82b49de5ba6ae197c166c73cd590775e7ac3a8f677a9a53cd4

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f5aad97982c2cf46d58bf56d3a962c63788e0efb7cbeb9d269f7d00f5ebc28dc
MD5 5bc4cb3d4eadc3493edef60abaaf69d6
BLAKE2b-256 7c16ab3dca2df937945713bde03980c79ce9a3fc87177673ab41d9c4fdd5af01

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 f85331838325ac195e3d43d9178b947f445a837196b4edf1348dfa4275d153e0
MD5 6b61b4755f5e67a6688cb6611d630012
BLAKE2b-256 5723db1970947639d0feb6aa67a1c5df173743a6c92141371c63cb91760b717f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 82b4892ee67162604eea9291e0c052a7a1c40da55aadc8379659f985161bfa3c
MD5 40c935de22ea178484f3803bc8a19d75
BLAKE2b-256 2d77b04235e2b61abb27ee53a880ca24ed6317e6c3be19ceadbf549b7b7c89e3

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 9fde6dba3e0aa0c9d253f0074467cdf0961604c00cd3ac465234d93973483290
MD5 a17286c49f0c07f46838d34a8d9a110d
BLAKE2b-256 b23700c95b41640ca2203fe9943536235729e112d495ec274f641f258e1bdacd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.1.0-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.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

File hashes

Hashes for backports.zoneinfo-0.1.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 cf08add78491b59b7bc2cb1e4f5f6f763e669081ed125e4e4f42d9751670230d
MD5 059eed133dfd2d0cdfdcf2efc5c6b07e
BLAKE2b-256 93b78bb7e9cac66b43549ea5d9fd850a554e3c308670daa60371d486b1e6ea35

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