{"id":4282,"library":"tonyg-rfc3339","title":"RFC 3339 Date/Time Utilities","description":"The `tonyg-rfc3339` library provides a Python implementation for parsing and formatting dates and times according to RFC 3339. It includes `tzinfo` classes for UTC and fixed-offset timezones, aiming for simple, standard, and robust timestamp handling across languages. The current version is 0.1, with its last PyPI release in 2015, suggesting a maintenance or stable status rather than active development.","status":"maintenance","version":"0.1","language":"en","source_language":"en","source_url":"https://github.com/cardforcoin/python-rfc3339","tags":["date","time","rfc3339","iso8601","timezone"],"install":[{"cmd":"pip install tonyg-rfc3339","lang":"bash","label":"Install from PyPI"}],"dependencies":[],"imports":[{"symbol":"parse_datetime","correct":"from rfc3339 import parse_datetime"},{"symbol":"generate_datetime","correct":"from rfc3339 import generate_datetime"},{"note":"The `UTC` constant for the timezone object is capitalized.","wrong":"from rfc3339 import Utc","symbol":"UTC","correct":"from rfc3339 import UTC"}],"quickstart":{"code":"from datetime import datetime, timedelta\nfrom rfc3339 import parse_datetime, generate_datetime, UTC\n\n# Example 1: Parsing an RFC 3339 timestamp\ntimestamp_str = \"2023-10-27T10:00:00Z\"\ndt_object = parse_datetime(timestamp_str)\nprint(f\"Parsed datetime: {dt_object}\")\n# Expected: Parsed datetime: 2023-10-27 10:00:00+00:00\n\n# Example 2: Parsing with an offset\noffset_timestamp_str = \"2023-10-27T12:00:00+02:00\"\ndt_offset_object = parse_datetime(offset_timestamp_str)\nprint(f\"Parsed datetime with offset: {dt_offset_object}\")\n# Expected: Parsed datetime with offset: 2023-10-27 12:00:00+02:00\n\n# Example 3: Generating an RFC 3339 timestamp from a datetime object\nnow_utc = datetime.now(UTC)\nrfc3339_output = generate_datetime(now_utc)\nprint(f\"Generated RFC 3339: {rfc3339_output}\")\n# Expected: Generated RFC 3339: 2026-04-11T18:42:00Z (example time)\n\n# Example 4: Comparing two equivalent timestamps (parsed from different zones)\nmidnight_utc = parse_datetime(\"2008-08-24T00:00:00Z\")\none_am_bst = parse_datetime(\"2008-08-24T01:00:00+01:00\")\nprint(f\"Are equivalent datetimes equal? {midnight_utc == one_am_bst}\")\n# Expected: True","lang":"python","description":"The quickstart demonstrates parsing RFC 3339 formatted strings into timezone-aware `datetime` objects and generating RFC 3339 strings from `datetime` objects. It also shows how to use the provided `UTC` timezone object and the library's ability to handle timezone offsets for comparison."},"warnings":[{"fix":"For broader ISO 8601 parsing, consider `pyiso8601` or `dateutil`. For simple RFC 3339, ensure input strictly adheres to the standard as defined in the library.","message":"The library explicitly states it 'sticks quite closely to the RFC 3339 profile of ISO 8601'. If you require parsing more general or less strict ISO 8601 formats, this library might not be suitable, and you may need alternatives like `pyiso8601`.","severity":"gotcha","affected_versions":"0.1"},{"fix":"Be aware of these limitations. If your use case involves these specific RFC 3339 nuances (e.g., handling leap seconds or unknown local offsets), this library will not provide the necessary functionality.","message":"The library does not implement 'Unknown Local Offset Convention' (RFC 3339 Section 4.3) and only supports 'Internet Date/Time Format' (Section 5.6) for parsing. Leap seconds are also not addressed.","severity":"gotcha","affected_versions":"0.1"},{"fix":"Evaluate if built-in `datetime` functionality (especially `isoformat()` and `fromisoformat()` in Python 3.7+) or other community libraries (e.g., `rfc3339lib`, `strict-rfc3339`) meet your needs more effectively, especially for newer Python versions or if active maintenance is a concern.","message":"For Python 3.2 and later, the built-in `datetime` module's `isoformat()` method can generate RFC 3339 compatible strings, and `datetime.fromisoformat()` (Python 3.7+) offers robust ISO 8601 parsing. More modern and actively maintained libraries like `rfc3339lib` or `strict-rfc3339` also exist.","severity":"deprecated","affected_versions":"All versions (due to evolving Python stdlib)"},{"fix":"Be aware that the library is not actively maintained on GitHub. For issues or contributions, consulting the 'moved to' URL might be necessary, though given its age, significant updates are unlikely.","message":"The GitHub repository notes that the project has 'MOVED TO: https://git.leastfixedpoint.com/tonyg/python-rfc3339'. This indicates the GitHub mirror may not be the primary development location, and active development or issue tracking might occur elsewhere, or not at all.","severity":"gotcha","affected_versions":"0.1"}],"env_vars":null,"last_verified":"2026-04-11T00:00:00.000Z","next_check":"2026-07-10T00:00:00.000Z"}