
    Yjs                     Z    d Z ddlmZ deez  dz  dedz  fdZdeez  dz  dedz  fdZdS )z-DateTime utilities for the Honcho Python SDK.    )datetimevalueNreturnc                 `    | dS t          | t                    r| S |                                 S )z
    Convert a datetime value to an ISO 8601 formatted string.

    Args:
        value: A datetime object, an ISO 8601 string, or None

    Returns:
        An ISO 8601 formatted string, or None if input is None
    N)
isinstancestr	isoformat)r   s    \/home/ubuntu/.hermes/hermes-agent/venv/lib/python3.11/site-packages/honcho/utils/datetime.pydatetime_to_isor      s5     }t% ??    c                     | dS t          | t                    r| S |                     dd          }	 t          j        |          S # t          $ r}t	          d|           |d}~ww xY w)a  
    Parse an ISO 8601 datetime string into a `datetime` instance.

    This accepts timestamps in the forms commonly produced by APIs and JS runtimes,
    including a trailing "Z" UTC designator (e.g. "2024-01-15T10:30:00Z") and
    offsets (e.g. "2024-01-15T10:30:00+00:00").

    Args:
        value: A datetime object, an ISO 8601 string, or None.

    Returns:
        A `datetime` instance if provided, otherwise None.

    Raises:
        ValueError: If the string cannot be parsed as ISO 8601.
    NZz+00:00zInvalid ISO 8601 datetime: )r   r   replacefromisoformat
ValueError)r   
normalizedes      r
   parse_datetimer      s    " }t%"" sH--JI%j111 I I I@u@@AAqHIs   A 
A)A$$A))__doc__r   r   r   r    r   r
   <module>r      s    3 3      8c>D0 S4Z    "I(S.4/ IHtO I I I I I Ir   