
    _il                       S r SSKJr  SSKrSSKJrJrJr  SSKJ	r	JrJ
r
Jr  SSKJr  SrS	r\R                   " \ S
35      r\R                   " \ S\ 35      r\" SSS5      r\" S5      r\" S5      rSS jrSS jrSS jrSS jrSS jrg)z
This file contains code from https://github.com/pydantic/pydantic/blob/main/pydantic/v1/datetime_parse.py
without the Pydantic v1 specific errors.
    )annotationsN)DictUnionOptional)datedatetimetimezone	timedelta   )StrBytesIntFloatz3(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})z(?P<hour>\d{1,2}):(?P<minute>\d{1,2})(?::(?P<second>\d{1,2})(?:\.(?P<microsecond>\d{1,6})\d{0,6})?)?(?P<tzinfo>Z|[+-]\d{2}(?::?\d{2})?)?$$z[T ]i     g    _Bg0)VC0Dc                    [        U [        [        45      (       a  U $  [        U 5      $ ! [         a     g [         a    [	        SU S35      S ef = f)Nzinvalid type; expected z, string, bytes, int or float)
isinstanceintfloat
ValueError	TypeError)valuenative_expected_types     Y/var/www/html/land-ocr/venv/lib/python3.13/site-packages/openai/_utils/_datetime_parse.py_get_numericr   !   s_    %#u&&qU|  q12F1GGdeflppqs   
* 
AAc                    U [         :  a  [        R                  $ U [         * :  a  [        R                  $ [	        U 5      [
        :  a  U S-  n [	        U 5      [
        :  a  M  [        [        U S9-   nUR                  [        R                  S9$ )Ni  )seconds)tzinfo)
MAX_NUMBERr   maxminabsMS_WATERSHEDEPOCHr
   replacer	   utc)r   dts     r   _from_unix_secondsr%   ,   so    ||	J;	||
g,
%4 g,
%	7+	+B::X\\:**    c                    U S:X  a  [         R                  $ U bQ  [        U 5      S:  a  [        U SS  5      OSnS[        U SS 5      -  U-   nU S   S:X  a  U* n[        [	        US95      $ g )	NZ   r   <   r   -)minutes)r	   r#   lenr   r
   )r   offset_minsoffsets      r   _parse_timezoner1   8   sr    |||		),Uac%*oQc%!*o%38s?WF	&122r&   c                V   [        U [        5      (       a  U $ [        U S5      nUb  [        U5      $ [        U [        5      (       a  U R                  5       n [        U [        [        45      (       a   e[        R                  U 5      nUc  [        S5      eUR                  5       nUS   (       a  US   R                  SS5      US'   [        UR                  S5      5      nUR                  5        VVs0 s H  u  pVUc  M
  U[        U5      _M     nnnXGS'   [        S0 UD6$ s  snnf )aC  
Parse a datetime/int/float/string and return a datetime.datetime.

This function supports time zone offsets. When the input contains one,
the output uses a timezone with a fixed offset from UTC.

Raise ValueError if the input is well formatted but not a valid datetime.
Raise ValueError if the input isn't well formatted.
r   zinvalid datetime formatmicrosecond   0r    )r   r   r   r%   bytesdecoder   r   datetime_rematchr   	groupdictljustr1   popitems)r   numberr:   kwr   kvkw_s           r   parse_datetimerD   E   s    %""%,F!&))%%%....e$E}233		B	-}-33As;=RVVH-.FHJ
1d
VW)!SV)
C1dM?c? 2es   6	D%D%c                d   [        U [        5      (       a'  [        U [        5      (       a  U R                  5       $ U $ [        U S5      nUb  [	        U5      R                  5       $ [        U [
        5      (       a  U R                  5       n [        U [        [        45      (       a   e[        R                  U 5      nUc  [        S5      eUR                  5       R                  5        VVs0 s H  u  p4U[        U5      _M     nnn [        S0 UD6$ s  snnf ! [         a    [        S5      Sef = f)z
Parse a date/int/float/string and return a datetime.date.

Raise ValueError if the input is well formatted but not a valid date.
Raise ValueError if the input isn't well formatted.
r   Nzinvalid date formatr6   )r   r   r   r   r%   r7   r8   r   r   date_rer:   r   r;   r>   )r   r?   r:   rA   rB   r@   s         r   
parse_daterG   j   s    %eX&&::<L%(F!&)..00%%%....MM% E}.// % 1 7 7 9	: 9!SV) 9B	::zbz 
;  :./T9:s   +D
D D/)r   r   r   strreturnzUnion[None, int, float])r   zUnion[int, float]rI   r   )r   zOptional[str]rI   zUnion[None, int, timezone])r   z!Union[datetime, StrBytesIntFloat]rI   r   )r   zUnion[date, StrBytesIntFloat]rI   r   )__doc__
__future__r   retypingr   r   r   r   r   r	   r
   _typesr   	date_expr	time_exprcompilerF   r9   r!   r   r    r   r   r%   r1   rD   rG   r6   r&   r   <module>rR      s   
 # 	 ( ( 8 8 %B	- 
 **	{!_
%jjI;d9+67 	q! 4yY
q	+
"J:r&   