Ë
    òmxiË  ã                   ó  — d Z ddlZddlZddlZddlmZ ej                  j                  dej                  j                  «      Z	dZ
dZ ej                  dej                  «      Zd„ Zdd„Z G d	„ d
ej                  «      Zy)zHelpers for :mod:`datetime`.é    N)Útimestamp_pb2z%Y-%m-%dT%H:%M:%S.%fZz%Y-%m-%dT%H:%M:%Sah  
    (?P<no_fraction>
        \d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}  # YYYY-MM-DDTHH:MM:SS
    )
    (                                        # Optional decimal part
     \.                                      # decimal point
     (?P<nanos>\d{1,9})                      # nanoseconds, maybe truncated
    )?
    Z                                        # Zulu
c                 ó<   — t         t        j                  | ¬«      z   S )a  Convert timestamp in microseconds since the unix epoch to datetime.

    Args:
        value (float): The timestamp to convert, in microseconds.

    Returns:
        datetime.datetime: The datetime object equivalent to the timestamp in
            UTC.
    )Úmicroseconds)Ú
_UTC_EPOCHÚdatetimeÚ	timedelta)Úvalues    úM/home/htdocs/ttos/venv/lib/python3.12/site-packages/proto/datetime_helpers.pyÚ_from_microsecondsr   ,   s   € ô œ×*Ñ*¸Ô>Ñ>Ð>ó    c                 óŽ   — |s/| j                   �#| j                  d¬«      | j                  «       z
  } | j                  t        «      S )a‡  Convert a datetime to an RFC3339 timestamp string.

    Args:
        value (datetime.datetime):
            The datetime object to be converted to a string.
        ignore_zone (bool): If True, then the timezone (if any) of the
            datetime object is ignored and the datetime is treated as UTC.

    Returns:
        str: The RFC3339 formatted string representing the datetime.
    N©Útzinfo)r   ÚreplaceÚ	utcoffsetÚstrftimeÚ_RFC3339_MICROS)r	   Úignore_zones     r
   Ú_to_rfc3339r   9   s;   € ñ ˜5Ÿ<™<Ð3à—‘ T�Ó*¨U¯_©_Ó->Ñ>ˆà�>‰>œ/Ó*Ð*r   c                   óh   ‡ — e Zd ZdZdZd„ Zˆ fd„Zed„ «       Zd„ Z	e
d„ «       Zd„ Ze
d	„ «       Zˆ xZS )
ÚDatetimeWithNanosecondszuTrack nanosecond in addition to normal datetime attrs.

    Nanosecond can be passed only as a keyword argument.
    )Ú_nanosecondc                 ó¾   — |j                  dd«      }|dkD  rd|v rt        d«      ‚|dz  |d<   t        j                  j                  | g|¢­i |¤Ž}|xs d|_        |S )NÚ
nanosecondr   Úmicrosecondú1Specify only one of 'microsecond' or 'nanosecond'éè  )ÚpopÚ	TypeErrorr   Ú__new__r   )ÚclsÚargsÚkwÚnanosÚinsts        r
   r    zDatetimeWithNanoseconds.__new__U   sl   € Ø—‘�| QÓ'ˆØ�1Š9Ø Ñ"ÜÐ SÓTÐTØ %¨¡ˆBˆ}ÑÜ× Ñ ×(Ñ(¨Ð:¨tÒ:°rÑ:ˆØ š: AˆÔØˆr   c                 óø   •— d|v }d|v }|j                  dd«      }| j                  }|r|rt        d«      ‚|r|dz  |d<   t        ‰| �  |i |¤Ž}|r|j
                  dz  |_        |S |r	||_        |S ||_        |S )a@  Return a date with the same value, except for those parameters given
        new values by whichever keyword arguments are specified. For example,
        if d == date(2002, 12, 31), then
        d.replace(day=26) == date(2002, 12, 26).
        NOTE: nanosecond and microsecond are mutually exclusive arguments.
        r   r   r   r   r   )r   r   r   Úsuperr   r   r   )	Úselfr"   r#   Úms_providedÚns_providedÚprovided_nsÚ
prev_nanosr%   Ú	__class__s	           €r
   r   zDatetimeWithNanoseconds.replace`   s¨   ø€ ð $ rÐ)ˆØ" bÐ(ˆØ—f‘f˜\¨1Ó-ˆà—_‘_ˆ
á™;ÜÐOÓPÐPáà +¨tÑ 3ˆBˆ}ÑÜ‰w‰ Ð+¨Ñ+ˆáà#×/Ñ/°$Ñ6ˆDÔð ˆñ à*ˆDÔð
 ˆð  *ˆDÔàˆr   c                 ó<   — | j                   xs | j                  dz  S )z Read-only: nanosecond precision.r   )r   r   )r(   s    r
   r   z"DatetimeWithNanoseconds.nanosecond‚   s    € ð ×ÑÒ: 4×#3Ñ#3°dÑ#:Ð:r   c                 óè   — | j                   dk(  rt        | «      S t        | j                   «      j                  dd«      j	                  d«      }dj                  | j                  t        «      |«      S )z€Return an RFC3339-compliant timestamp.

        Returns:
            (str): Timestamp string according to RFC3339 spec.
        r   é	   Ú0z{}.{}Z)r   r   ÚstrÚrjustÚrstripÚformatr   Ú_RFC3339_NO_FRACTION)r(   r$   s     r
   Úrfc3339zDatetimeWithNanoseconds.rfc3339‡   s`   € ð ×Ñ˜qÒ Ü˜tÓ$Ð$Ü�D×$Ñ$Ó%×+Ñ+¨A¨sÓ3×:Ñ:¸3Ó?ˆØ�‰˜tŸ}™}Ô-AÓBÀEÓJÐJr   c           
      ó  — t         j                  |«      }|€)t        dj                  |t         j                  «      «      ‚t
        j
                  j                  |j                  d«      t        «      }|j                  d«      }|€d}ndt        |«      z
  }t        |«      d|z  z  } | |j                  |j                  |j                  |j                  |j                  |j                   |t
        j"                  j$                  ¬«      S )ak  Parse RFC3339-compliant timestamp, preserving nanoseconds.

        Args:
            stamp (str): RFC3339 stamp, with up to nanosecond precision

        Returns:
            :class:`DatetimeWithNanoseconds`:
                an instance matching the timestamp string

        Raises:
            ValueError: if `stamp` does not match the expected format
        z)Timestamp: {}, does not match pattern: {}Úno_fractionr$   r   r0   é
   ©r   r   )Ú_RFC3339_NANOSÚmatchÚ
ValueErrorr5   Úpatternr   ÚstrptimeÚgroupr6   ÚlenÚintÚyearÚmonthÚdayÚhourÚminuteÚsecondÚtimezoneÚutc)r!   ÚstampÚ
with_nanosÚbareÚfractionr$   Úscales          r
   Úfrom_rfc3339z$DatetimeWithNanoseconds.from_rfc3339’   sï   € ô $×)Ñ)¨%Ó0ˆ
ØÐÜØ;×BÑBØœ>×1Ñ1óóð ô
 × Ñ ×)Ñ)Ø×Ñ˜]Ó+Ô-Aó
ˆð ×#Ñ# GÓ,ˆØÐØ‰Eàœ˜H›Ñ%ˆEÜ˜“M R¨¡YÑ/ˆEÙØ�I‰IØ�J‰JØ�H‰HØ�I‰IØ�K‰KØ�K‰KØÜ×$Ñ$×(Ñ(ô	
ð 		
r   c                 ó  — | j                   �| n)| j                  t        j                  j                  ¬«      }|t
        z
  }t        |j                  «       «      }| j                  xs | j                  dz  }t        j                  ||¬«      S )z‰Return a timestamp message.

        Returns:
            (:class:`~google.protobuf.timestamp_pb2.Timestamp`): Timestamp message
        r   r   )Úsecondsr$   )r   r   r   rJ   rK   r   rC   Útotal_secondsr   r   r   Ú	Timestamp)r(   r%   ÚdeltarS   r$   s        r
   Útimestamp_pbz$DatetimeWithNanoseconds.timestamp_pb»   s   € ð �{‰{Ð&ñ à—‘¤X×%6Ñ%6×%:Ñ%:�Ó;ð 	ð
 ”zÑ!ˆÜ�e×)Ñ)Ó+Ó,ˆØ× Ñ Ò; D×$4Ñ$4°tÑ$;ˆÜ×&Ñ&¨w¸eÔDÐDr   c           
      ó$  — t        |j                  dz  «      }t        |«      } | |j                  |j                  |j
                  |j                  |j                  |j                  |j                  t        j                  j                  ¬«      S )a&  Parse RFC3339-compliant timestamp, preserving nanoseconds.

        Args:
            stamp (:class:`~google.protobuf.timestamp_pb2.Timestamp`): timestamp message

        Returns:
            :class:`DatetimeWithNanoseconds`:
                an instance matching the timestamp message
        g    €„.Ar;   )rC   rS   r   rD   rE   rF   rG   rH   rI   r$   r   rJ   rK   )r!   rL   r   rN   s       r
   Úfrom_timestamp_pbz)DatetimeWithNanoseconds.from_timestamp_pbË   sn   € ô ˜5Ÿ=™=¨3Ñ.Ó/ˆÜ! ,Ó/ˆÙØ�I‰IØ�J‰JØ�H‰HØ�I‰IØ�K‰KØ�K‰KØ—{‘{Ü×$Ñ$×(Ñ(ô	
ð 		
r   )Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú	__slots__r    r   Úpropertyr   r7   ÚclassmethodrQ   rW   rY   Ú__classcell__)r-   s   @r
   r   r   L   sc   ø„ ñð
 !€Iòô ðD ñ;ó ð;ò	Kð ñ&
ó ð&
òPEð  ñ
ó ô
r   r   )T)r]   Úcalendarr   ÚreÚgoogle.protobufr   ÚfromtimestamprJ   rK   r   r   r6   ÚcompileÚVERBOSEr<   r   r   r   © r   r
   ú<module>ri      sƒ   ðñ #ã Û Û 	å )ð ×Ñ×,Ñ,¨Q°×0AÑ0A×0EÑ0EÓF€
à)€Ø*Ð à�—‘ð	ð ‡J�Jó€ò
?ó+ô&U
˜h×/Ñ/õ U
r   