
    g
                     (    d Z ddlmZmZ dedefdZy)z:Contains utilities to handle datetimes in Huggingface Hub.    )datetimetimezonedate_stringreturnc                 0   	 | j                  d      r0d| vr	| dd dz   } n#| dd j                  d      \  }}| d|dd dd} t        j                  | d      j	                  t
        j                  	      S # t        $ r}t        d
|  d      |d}~ww xY w)a  
    Parses a date_string returned from the server to a datetime object.

    This parser is a weak-parser is the sense that it handles only a single format of
    date_string. It is expected that the server format will never change. The
    implementation depends only on the standard lib to avoid an external dependency
    (python-dateutil). See full discussion about this decision on PR:
    https://github.com/huggingface/huggingface_hub/pull/999.

    Example:
        ```py
        > parse_datetime('2022-08-19T07:19:38.123Z')
        datetime.datetime(2022, 8, 19, 7, 19, 38, 123000, tzinfo=timezone.utc)
        ```

    Args:
        date_string (`str`):
            A string representing a datetime returned by the Hub server.
            String is expected to follow '%Y-%m-%dT%H:%M:%S.%fZ' pattern.

    Returns:
        A python datetime object.

    Raises:
        :class:`ValueError`:
            If `date_string` cannot be parsed.
    Z.Nz.000000Z   z0<6z%Y-%m-%dT%H:%M:%S.%fZ)tzinfozCannot parse 'zS' as a datetime. Date string is expected to follow '%Y-%m-%dT%H:%M:%S.%fZ' pattern.)endswithsplitr   strptimereplacer   utc
ValueError)r   basefractiones       T/var/www/openai/venv/lib/python3.12/site-packages/huggingface_hub/utils/_datetime.pyparse_datetimer      s    8$+%)#2.; "-Sb!1!7!7!<h!%a!S'9;  .EFNNV^VbVbNcc [M *7 7
 	s   A4A7 7	B BBN)__doc__r   r   strr        r   <module>r      s!    A '/ / /r   