---
title: "backports.zoneinfo | pypx"
description: "Backport of the standard library zoneinfo module"
canonical_url: "https://pypx.app/packages/backports-zoneinfo"
meta:
  "og:description": "Backport of the standard library zoneinfo module"
  "og:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_backports.zoneinfo%2Cversion_0.2.1%2Csummary_Backport%2Bof%2Bthe%2Bstandard%2Blibrary%2Bzoneinfo%2Bmodule%2Clicense_Apache%2BSoftware%2BLicense%2Cp_Ii9wYWNrYWdlcy9iYWNrcG9ydHMtem9uZWluZm8i%2Cs_poCDluYcQIhKaHOX.png"
  "og:image:height": "630"
  "og:image:type": image/png
  "og:image:width": "1200"
  "og:title": "backports.zoneinfo 0.2.1"
  "twitter:image": "https://pypx.app/_og/d/h_630%2Cc_PackageCard%2Cname_backports.zoneinfo%2Cversion_0.2.1%2Csummary_Backport%2Bof%2Bthe%2Bstandard%2Blibrary%2Bzoneinfo%2Bmodule%2Clicense_Apache%2BSoftware%2BLicense%2Cp_Ii9wYWNrYWdlcy9iYWNrcG9ydHMtem9uZWluZm8i%2Cs_poCDluYcQIhKaHOX.png"
---

> Index of every page on this site: [llms.txt](https://pypx.app/llms.txt)

# **backports.zoneinfo**

v0.2.1

Backport of the standard library zoneinfo module

35 KB Python 3.6+ platform-specificApache Software License2 deps Likely Unmaintained

[**Diff **](https://pypx.app/packages/backports.zoneinfo/diff)

`$ uv add backports.zoneinfo`

# `backports.zoneinfo`: Backport of the standard library module `zoneinfo`

This package was originally the reference implementation for [PEP 615](https://www.python.org/dev/peps/pep-0615/), 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`](https://docs.python.org/3.9/library/zoneinfo.html#module-zoneinfo) module. The backport's documentation can be found [on readthedocs](https://zoneinfo.readthedocs.io/en/latest/).

The module uses the system time zone data if available, and falls back to the [`tzdata`](https://tzdata.readthedocs.io/en/latest/) package (available [on PyPI](https://pypi.org/project/tzdata/)) if installed.

## Installation and depending on this library

This module is called [`backports.zoneinfo`](https://pypi.org/project/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](https://www.python.org/dev/peps/pep-0508/#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](https://www.python.org/dev/peps/pep-0495/):

```
>>> 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](https://github.com/python/cpython) will eventually be backported to this repository — see [the Python developer's guide](https://devguide.python.org/) for more information on how to contribute to CPython.

## **Details **

<dl>

<dt>Version</dt>
<dd>0.2.1</dd>

<dt>License</dt>
<dd>Apache Software License</dd>

<dt>Python</dt>
<dd>&gt;=3.6</dd>

<dt>Maintainer</dt>
<dd>Python Software Foundation</dd></dl>

## **Links**

- [Bug Reports](https://github.com/pganssle/zoneinfo/issues)
- [Documentation](https://zoneinfo.readthedocs.io/en/latest/)
- [Homepage](https://github.com/pganssle/zoneinfo)
- [Source](https://github.com/pganssle/zoneinfo)
- [View on PyPI](https://pypi.org/project/backports.zoneinfo/)

## **Platforms **

linuxmac-x86win

## **Maintainers **

- Python Software Foundation · [datetime-sig@python.org](mailto:datetime-sig@python.org)

```json
{"@context":"https://schema.org","@graph":[{"@id":"https://pypx.app/#website","@type":"WebSite","description":"The Python Package Index, reimagined. Fast search, dependency insights, download trends, and changelogs — all in one place.","name":"pypx","url":"https://pypx.app/"},{"@id":"https://pypx.app/packages/backports-zoneinfo#webpage","@type":"WebPage","description":"Backport of the standard library zoneinfo module","name":"backports.zoneinfo","url":"https://pypx.app/packages/backports-zoneinfo","isPartOf":{"@id":"https://pypx.app/#website"},"potentialAction":[{"@type":"ReadAction","target":["https://pypx.app/packages/backports-zoneinfo"]}]},{"@id":"https://pypx.app/packages/backports-zoneinfo#/schema/software-application/1","@type":"SoftwareApplication","applicationCategory":"DeveloperApplication","description":"Backport of the standard library zoneinfo module","license":"Apache Software License","name":"backports.zoneinfo","softwareVersion":"0.2.1"}]}
```

## Sitemap

See the full [sitemap](https://pypx.app/sitemap.md) for all pages.
