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

Uploaded Source

Built Distributions

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

Uploaded CPython 3.8 Windows x86-64

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

Uploaded CPython 3.8 Windows x86

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

Uploaded CPython 3.7m Windows x86-64

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

Uploaded CPython 3.7m Windows x86

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

Uploaded CPython 3.7m

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

Uploaded CPython 3.6m Windows x86-64

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

Uploaded CPython 3.6m Windows x86

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

Uploaded CPython 3.6m

backports.zoneinfo-0.2.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.2.0.tar.gz.

File metadata

  • Download URL: backports.zoneinfo-0.2.0.tar.gz
  • Upload date:
  • Size: 73.6 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.2.0.tar.gz
Algorithm Hash digest
SHA256 23b39f0a0ab4a640091ec7c20846e7d90bda98f88e6117e5f417c2b0a5564590
MD5 2d3ae7eff4e0483e58f967919d44867a
BLAKE2b-256 cbc0158dd4a82e43b0216f8fb050b6779726294302d79e9d56ff6b6588d07022

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp38-cp38-win_amd64.whl
Algorithm Hash digest
SHA256 658a4e4f2e9a2fd9b870b7301a281ab4831f67845df1e4c1022df39396e81827
MD5 66cb8308710fd32337a0d3f09d5fee45
BLAKE2b-256 f2e90012a1f35b4a1b4d8ff101b76cb9f40bcca5bdd3710a2ecf3c129cdd2c1a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp38-cp38-win32.whl
Algorithm Hash digest
SHA256 d48572dca821325c7febc25efd7d7da59e4c7ea84925cc0c3cd10527fde50e20
MD5 503561dff0072d6a79168c53caa87aa0
BLAKE2b-256 9f3a49c360ab98752f9f653079859e022e6c60f88226c910ec0608ee8f3ad10a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp38-cp38-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 d7bc29e9c524e948e1201674c6c8fa71cf3d0eb79d0b7117d96967e3a7447cb9
MD5 5cdcb0b1a72d7ea603386ddf52f448ca
BLAKE2b-256 5d017c473917e1c705a471296b94dfe742f33cb196fa94946cfb4fd304f2f635

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp38-cp38-manylinux1_i686.whl
Algorithm Hash digest
SHA256 ca4ff0229810329eeaee954fb0422794a145d00cb8cdf6f259d89f835fdc9c13
MD5 470caf94f44d50f0b5a2c26a5f4d18b3
BLAKE2b-256 c7fc40828234ebb09f7e163795dba39c3b392f7e388317fd2a1e0df6ae284068

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp38-cp38-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 728085c09decc8e25ecd67d5601de3231171cf8569a1b464e3748419d07fcd8e
MD5 adad10da46ae64be93fc988114cbfc6d
BLAKE2b-256 6c413c4db99a9c7ee146d0bb05998dac932d39d4ab0fe0384eab5c4274f043cd

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp37-cp37m-win_amd64.whl
Algorithm Hash digest
SHA256 551e71f3be794b45d4070f56d0a422d58a86d498d18862bccadaa1e6061511f2
MD5 ca39a1d6e13163644b9d606263ab44ba
BLAKE2b-256 5033dbae9c84cc093c5137a3481a6b926698e583b0512b8167987ed0f465e98f

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp37-cp37m-win32.whl
Algorithm Hash digest
SHA256 5c1f686557341ffe53cce331b40f4e5a7388ddbb1a6324261070a3b490db5dc9
MD5 35718b150e6b2f52b708d627ebd7f723
BLAKE2b-256 f041c0716b5a21e77b2a7961a8e88b40fddb6377eaa68fe3b2c8384e99c2e4c3

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp37-cp37m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 c8e5d61dd9d130e853aa7a9fc23cd3e4b5a98e7bf4a3b8cefb68afd37bf0160b
MD5 976130d54ea1987e0573608043e5c3b9
BLAKE2b-256 779f65eef4b040a98470c01f0126594ec8c17067a22387c03a841cb5c2a950fa

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp37-cp37m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 c28b0e13275682c61844ba30835b6b59986e31c59f1176506416d85dbdb6d199
MD5 7c874a7930ae654fd84f371980b8fb21
BLAKE2b-256 3af4324a0b66827c4711474a0ab420fbd32b3e5775f261e91a124b50e89c249c

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp37-cp37m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 4596f7d2b6ded0525359bdf4d8940128c0c840e762728f8ee4efc8cbc5a8aa53
MD5 4babb9d7695187e1503faf9274381a6e
BLAKE2b-256 687aff0e6c1adc0daca0a2fbd1f12c16ab43eb7750547d83af0850ba1317da0b

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp36-cp36m-win_amd64.whl
Algorithm Hash digest
SHA256 f778bf7b8210970ff8fea9060eea452dc3747fa0a79f81fa33708c6b9a043ef2
MD5 f8fd439da8ed88f358f26165c4e3238c
BLAKE2b-256 6f3db8d87841c15209222e6f4b98c25c51a2298daa4aeea30b67d70f76c1a198

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp36-cp36m-win32.whl
Algorithm Hash digest
SHA256 ea3ecb3f816e4bac96e0562660340cc1e063ae5bb04f7128af69c2d83019ccb2
MD5 bdc1df81ce13ca004974385bea8af196
BLAKE2b-256 127f62d9ce246fdb23ebca98096d9a757306b63676d3baf1eda0c4548dcadf20

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp36-cp36m-manylinux1_x86_64.whl
Algorithm Hash digest
SHA256 ff638c552cf342a31cb8bdb7e4e4c1fcac61d01c23e109f72e11a23631107765
MD5 69c7c66dca24def729a2e1d16441c797
BLAKE2b-256 8d4df84074bc450761ceef7bd8efc5c6935ae665a87dbc423c3e98ac56e2c35a

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp36-cp36m-manylinux1_i686.whl
Algorithm Hash digest
SHA256 7cdedc966a61cdaf1a7069468f9a0208b35a7eb90135a989c9ec9e4fe771d89d
MD5 8da5a81f26d16ee29d3f4663c7dcf556
BLAKE2b-256 0a78b67627ef75dd6281ca57bb6596bd9eb6afe935c4fbeb6d53420e6d016232

See more details on using hashes here.

File details

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

File metadata

  • Download URL: backports.zoneinfo-0.2.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.2.0-cp36-cp36m-macosx_10_14_x86_64.whl
Algorithm Hash digest
SHA256 46e99bcc81476e3f6f430b78a4485fb6d0fab2ce2ab6f1c4de8ba1d89469b029
MD5 290a8d40e7d1552dfde4c6e719695911
BLAKE2b-256 6fec0a815c58e4d2b2af371ba5df89931b5b0e8835329149e809edf3a92be8a6

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