aniso8601 is a Python library designed for robust parsing of ISO 8601 strings into native Python `datetime` and `timedelta` objects. It supports durations, dates, times, and datetimes, adhering strictly to the ISO 8601 standard. The current version is 10.0.1, and it maintains an active, though irregular, release cadence.
pip install aniso8601Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates parsing ISO 8601 duration and datetime strings using `aniso8601.parse.parse_duration` and `aniso8601.parse.parse_datetime`. It also shows how to catch `ISO8601Error` for invalid inputs.
Update code to expect `datetime.timedelta` and `datetime.datetime` objects. If custom behavior was required, consider extending native types or reimplementing logic.
Upgrade to Python 3.7 or newer. Remove calls to `parse_repeating_interval` and implement custom logic if needed. Update exception import paths from `aniso8601.exceptions` to `aniso8601`.
Ensure input strings are strictly ISO 8601 compliant. Validate inputs before passing them to aniso8601 parsing functions, or wrap calls in `try...except aniso8601.ISO8601Error` blocks.
Always provide timezone information (e.g., '2023-01-15T10:00:00Z' for UTC or '+01:00' for an offset) if you require timezone-aware datetime objects. If you receive a naive datetime, you must explicitly localize it using a library like `pytz` or `zoneinfo` (Python 3.9+).
Refactor import statements. Instead of `import aniso8601.parse` or `from aniso8601.parse import ...`, use `from aniso8601 import ...` to access parsing functions directly from the `aniso8601` package (e.g., `from aniso8601 import parse_datetime`).
Update import statements. Parsing functions (e.g., `parse_datetime`, `parse_duration`) should be imported directly from the top-level `aniso8601` package (e.g., `from aniso8601 import parse_datetime`).
No dependency data recorded yet.