{"library":"pyrfc3339","title":"RFC 3339 Timestamp Library","description":"pyRFC3339 parses and generates RFC 3339-compliant timestamps using Python datetime.datetime objects. It aims to simplify timestamp parsing and generation, leveraging improvements in native Python capabilities. The current stable version is 2.1.0, released on August 23, 2025. It appears to be actively maintained with recent releases and GitHub activity.","status":"active","version":"2.1.0","language":"en","source_language":"en","source_url":"https://github.com/kurtraschke/pyRFC3339.git","tags":["RFC 3339","timestamp","datetime","parsing","generation","ISO 8601"],"install":[{"cmd":"pip install pyrfc3339","lang":"bash","label":"Install stable version"}],"dependencies":[],"imports":[{"symbol":"generate, parse","correct":"from pyrfc3339 import generate, parse"}],"quickstart":{"code":"from datetime import datetime, timezone, timedelta\nfrom pyrfc3339 import generate, parse\n\n# Get current UTC time and generate RFC 3339 string\nnow_utc = datetime.now(timezone.utc)\nprint(f\"Current UTC: {now_utc.isoformat()}\")\nrfc3339_timestamp = generate(now_utc)\nprint(f\"Generated RFC 3339: {rfc3339_timestamp}\")\n\n# Parse an RFC 3339 timestamp\nparsed_dt_utc = parse('2009-01-01T10:01:02Z')\nprint(f\"Parsed UTC: {parsed_dt_utc}\")\n\n# Parse with an offset\nparsed_dt_offset = parse('2009-01-01T14:01:02-04:00')\nprint(f\"Parsed with offset: {parsed_dt_offset}\")\n\n# Example of generating from a naive datetime (requires accept_naive=True)\ntry:\n    generate(datetime(2023, 1, 1, 12, 0, 0))\nexcept ValueError as e:\n    print(f\"Expected error for naive datetime: {e}\")\n\nnaive_as_utc = generate(datetime(2023, 1, 1, 12, 0, 0), accept_naive=True)\nprint(f\"Generated from naive (as UTC): {naive_as_utc}\")","lang":"python","description":"Demonstrates how to generate RFC 3339 timestamps from timezone-aware `datetime` objects and parse RFC 3339 strings back into `datetime` objects, including handling of naive datetimes for generation."},"warnings":[{"fix":"Upgrade Python to 3.9+ or pin `pyrfc3339<2.0.0`.","message":"Version 2.0 and later of `pyrfc3339` require Python 3.9 or higher. Users on Python 3.8 or older must remain on a `pyrfc3339` 1.x release or upgrade their Python interpreter.","severity":"breaking","affected_versions":">=2.0.0"},{"fix":"Ensure `datetime` objects are timezone-aware (e.g., `datetime.now(timezone.utc)`), or explicitly pass `accept_naive=True` to treat naive datetimes as UTC.","message":"`generate()` by default requires timezone-aware `datetime` objects. Passing a 'naive' datetime (one without timezone information) will raise a `ValueError`.","severity":"gotcha","affected_versions":"All"},{"fix":"Carefully manage `produce_naive` based on whether downstream code expects timezone-aware or naive datetimes. Prefer `utc=True` for consistent UTC output when a timezone is present in the string, or ensure `tzinfo` is handled if `produce_naive=True`.","message":"When using `parse()`, if `produce_naive=True` is specified, the returned `datetime` object will not have `tzinfo` attached. This can lead to unexpected behavior if subsequent operations expect a timezone-aware `datetime`.","severity":"gotcha","affected_versions":"All"},{"fix":"Be aware that not all parsed timestamps might be strictly RFC 3339 compliant, even if `pyrfc3339` successfully parses them. If strict validation is required, additional checks might be necessary.","message":"`parse()` delegates to Python's native `datetime.datetime.fromisoformat()`. While generally effective, this means it may accept some ISO 8601 formatted timestamps that do not strictly adhere to all nuances of RFC 3339.","severity":"gotcha","affected_versions":"All"}],"env_vars":null,"last_verified":"2026-04-05T00:00:00.000Z","next_check":"2026-07-04T00:00:00.000Z"}