Parse ISO format datetime string with timezone awareness. This converts from the localized ISO format returned by serialize_datetime back to a datetime object with proper timezone handling. Returns None if dt_str is None.
(dt_str: Optional[str])
| 1055 | |
| 1056 | |
| 1057 | def parse_datetime(dt_str: Optional[str]) -> Optional[datetime]: |
| 1058 | """ |
| 1059 | Parse ISO format datetime string with timezone awareness. |
| 1060 | |
| 1061 | This converts from the localized ISO format returned by serialize_datetime |
| 1062 | back to a datetime object with proper timezone handling. |
| 1063 | |
| 1064 | Returns None if dt_str is None. |
| 1065 | """ |
| 1066 | if not dt_str: |
| 1067 | return None |
| 1068 | |
| 1069 | try: |
| 1070 | # Use the Localization singleton for consistent timezone handling |
| 1071 | return Localization.get().localtime_str_to_utc_dt(dt_str) |
| 1072 | except ValueError as e: |
| 1073 | raise ValueError(f"Invalid datetime format: {dt_str}. Expected ISO format. Error: {e}") |
| 1074 | |
| 1075 | |
| 1076 | def serialize_task_schedule(schedule: TaskSchedule) -> Dict[str, str]: |
no test coverage detected