The `rfc3339` library for Python provides utilities to format `datetime` objects into RFC 3339 compliant strings and to parse such strings back into `datetime` objects. It closely adheres to the RFC 3339 standard, including providing its own UTC `tzinfo` implementation. While the PyPI package `6.2` was last released in 2019, the primary GitHub repository shows recent maintenance activity, indicating it's still actively maintained, albeit with a slow release cadence.
pip install rfc3339Verified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to format a `datetime` object into an RFC 3339 compliant string and parse such a string back into a `datetime` object using the `rfc3339` library. It also includes an example of parsing a string with a specific timezone offset.
Applications requiring precise handling of leap seconds must implement custom logic or use specialized libraries that provide this functionality, as it's not handled by standard Python `datetime` or this library.
When dealing with timestamps that might originate from systems using the 'Unknown Local Offset Convention', verify how the specific string format is handled. For strict adherence, consider manual parsing or pre-processing if '-00:00' must carry this specific semantic meaning.
Ensure input strings strictly adhere to the 'Internet Date/Time Format' profile (e.g., 'T' separator, explicit offset like 'Z' or '+HH:MM'). If you encounter parsing failures for valid RFC 3339 strings, inspect their exact format against Section 5.6 of the RFC.
Always ensure your `datetime` objects are timezone-aware (e.g., created with `timezone.utc` or `pytz` timezones) before passing them to `rfc3339` functions for consistent results. Avoid mixing timezone-aware and naive `datetime` objects.
No dependency data recorded yet.