{"library":"ciso8601","code":"import ciso8601\n\n# Parse a naive datetime string\ndate_str_naive = \"2023-10-27T10:00:00\"\ndt_naive = ciso8601.parse_datetime(date_str_naive)\nprint(f\"Naive: {dt_naive} (Type: {type(dt_naive)}) (TZ: {dt_naive.tzinfo})\")\n\n# Parse a timezone-aware datetime string\ndate_str_aware = \"2023-10-27T10:00:00+01:00\"\ndt_aware = ciso8601.parse_datetime(date_str_aware)\nprint(f\"Aware: {dt_aware} (Type: {type(dt_aware)}) (TZ: {dt_aware.tzinfo})\")\n\n# Parse as naive, even if timezone is present\ndate_str_aware_to_naive = \"2023-10-27T10:00:00Z\"\ndt_forced_naive = ciso8601.parse_datetime_as_naive(date_str_aware_to_naive)\nprint(f\"Forced Naive: {dt_forced_naive} (Type: {type(dt_forced_naive)}) (TZ: {dt_forced_naive.tzinfo})\")\n\n# Strict RFC 3339 parsing\n# RFC 3339 requires a full date and time with a timezone offset or 'Z'\ntry:\n    dt_rfc3339 = ciso8601.parse_rfc3339(\"2023-10-27T10:00:00Z\")\n    print(f\"RFC3339: {dt_rfc3339} (TZ: {dt_rfc3339.tzinfo})\")\n    ciso8601.parse_rfc3339(\"2023-10-27\") # This will raise ValueError\nexcept ValueError as e:\n    print(f\"Error parsing non-RFC3339 string with parse_rfc3339: {e}\")","lang":"python","description":"This quickstart demonstrates basic parsing of ISO 8601 strings, including naive and timezone-aware datetimes. It also shows how to explicitly parse as naive, ignoring timezone information, and how to use the strict RFC 3339 parser.","tag":null,"tag_description":null,"last_tested":"2026-04-24","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}