MCPcopy
hub / github.com/agent0ai/agent-zero / parse_datetime

Function parse_datetime

helpers/task_scheduler.py:1057–1073  ·  view source on GitHub ↗

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])

Source from the content-addressed store, hash-verified

1055
1056
1057def 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
1076def serialize_task_schedule(schedule: TaskSchedule) -> Dict[str, str]:

Callers 3

_task_plan_from_inputFunction · 0.90
parse_task_planFunction · 0.85
deserialize_taskFunction · 0.85

Calls 2

getMethod · 0.45

Tested by

no test coverage detected