easy +8 pts

Format date output

Convert ISO date strings into friendly US-style formats with weekday and timezone.

Write a function `format_date_output(date_str: str) -> str` that takes an ISO 8601 date-time string (with timezone offset) and returns a formatted string in the format: `Weekday, Month DD, YYYY HH:MM AM/PM` - Use the timezone from the input string (do NOT convert to UTC). - The weekday and month should be the full English names (e.g., Monday, January). - The day should be zero-padded to two digits (e.g., 05). - The time should be in 12-hour format with AM/PM (e.g., 03:05 PM). - If the input string is invalid or cannot be parsed, raise a `ValueError`. Examples: - `format_date_output("2024-05-14T09:30:00+02:00")` returns `"Tuesday, May 14, 2024 09:30 AM"` - `format_date_output("2020-12-25T23:15:00-05:00")` returns `"Friday, December 25, 2020 11:15 PM"` - `format_date_output("2023-01-01T00:05:00Z")` returns `"Sunday, January 01, 2023 12:05 AM"`

Constraints

The input string is a non-empty string containing a valid ISO 8601 date-time with timezone offset (e.g., `+02:00`, `-05:00`, `Z`). It will always include seconds. The function must raise `ValueError` for any invalid input. Do not modify the timezone.

Example

>>> format_date_output("2024-05-14T09:30:00+02:00")
'Tuesday, May 14, 2024 09:30 AM'
>>> format_date_output("2020-12-25T23:15:00-05:00")
'Friday, December 25, 2020 11:15 PM'
>>> format_date_output("2023-01-01T00:05:00Z")
'Sunday, January 01, 2023 12:05 AM'
8 points ~10 min

Recent Submissions

No submissions yet — hit Run Tests to try!

Hints

Use `datetime.fromisoformat` to parse the string; it handles timezone offsets and `Z` may need replacing with `+00:00`.
Use `strftime` with `%A, %B %d, %Y %I:%M %p` to get the desired format.
Ensure the timezone is preserved by using the parsed datetime object directly.
Python 3
All tests passed!
Test Results
Press Ctrl+Enter or click Run Tests to execute your code.