This library provides a backport of Python 3.11's extended `datetime.fromisoformat` functionality to older Python versions (prior to 3.11). It allows parsing a wider range of ISO 8601 formatted strings, including those with timezone offsets using colons and fractional seconds. The current version is 2.0.3, with releases occurring on an as-needed basis to address compatibility or new Python version changes.
pip install "backports-datetime-fromisoformat; python_version < '3.11'"Verified import paths — ran on the pinned version, not inferred.
This example demonstrates how to use the backported `fromisoformat` method. By importing `backports.datetime_fromisoformat` after `datetime`, it monkey-patches the standard library's `datetime` objects to accept ISO 8601 strings that conform to Python 3.11's broader parsing capabilities, such as timezone offsets with colons.
Always ensure `import datetime` appears before `import backports.datetime_fromisoformat` in your code.
Applications migrating from 1.x.x to 2.x.x should be aware that `fromisoformat` will now accept more varied ISO 8601 strings. This is generally an improvement, but verify if any strict parsing assumptions were made based on older 3.7 behavior.
Conditionally install the package using environment markers in your `pyproject.toml` or `requirements.txt`: `backports-datetime-fromisoformat; python_version < '3.11'`.
No dependency data recorded yet.