HEX
Server: LiteSpeed
System: Linux php-prod-1.spaceapp.ru 5.15.0-157-generic #167-Ubuntu SMP Wed Sep 17 21:35:53 UTC 2025 x86_64
User: sport3497 (1034)
PHP: 8.1.33
Disabled: NONE
Upload Files
File: //usr/local/CyberCP/lib/python3.10/site-packages/proto/__pycache__/datetime_helpers.cpython-310.pyc
o

�h��@sxdZddlZddlZddlZddlmZej�dejj�Z	dZ
dZe�dej
�Zdd�Zdd
d�ZGdd
�d
ej�ZdS)zHelpers 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
cCsttj|d�S)aConvert 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)�value�r�I/usr/local/CyberCP/lib/python3.10/site-packages/proto/datetime_helpers.py�_from_microseconds,s
r
TcCs,|s|jdur|jdd�|��}|�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_zonerrr	�_to_rfc33399s
rcs`eZdZdZdZdd�Z�fdd�Zedd��Zd	d
�Z	e
dd��Zd
d�Ze
dd��Z
�ZS)�DatetimeWithNanosecondszuTrack nanosecond in addition to normal datetime attrs.

    Nanosecond can be passed only as a keyword argument.
    )�_nanosecondcOsX|�dd�}|dkrd|vrtd��|d|d<tjj|g|�Ri|��}|p(d|_|S)N�
nanosecondr�microsecond�1Specify only one of 'microsecond' or 'nanosecond'��)�pop�	TypeErrorr�__new__r)�cls�args�kw�nanos�instrrr	rUs
zDatetimeWithNanoseconds.__new__cs�d|v}d|v}|�dd�}|j}|r|rtd��|r!|d|d<t�j|i|��}|r4|jd|_|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.
        rrrrr)rrr�superr
rr)�selfrr�ms_provided�ns_provided�provided_ns�
prev_nanosr ��	__class__rr	r
`s"��zDatetimeWithNanoseconds.replacecCs|jp|jdS)z Read-only: nanosecond precision.r)rr)r"rrr	r�sz"DatetimeWithNanoseconds.nanosecondcCs<|jdkr	t|�St|j��dd��d�}d�|�t�|�S)z�Return an RFC3339-compliant timestamp.

        Returns:
            (str): Timestamp string according to RFC3339 spec.
        r�	�0z{}.{}Z)rr�str�rjust�rstrip�formatr�_RFC3339_NO_FRACTION)r"rrrr	�rfc3339�s
zDatetimeWithNanoseconds.rfc3339c
Cs�t�|�}|durtd�|tj���tj�|�d�t�}|�d�}|dur(d}ndt	|�}t
|�d|}||j|j|j
|j|j|j|tjjd�S)	akParse 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
        Nz)Timestamp: {}, does not match pattern: {}�no_fractionrrr)�
�rr)�_RFC3339_NANOS�match�
ValueErrorr.�patternr�strptime�groupr/�len�int�year�month�day�hour�minute�second�timezone�utc)r�stamp�
with_nanos�bare�fractionr�scalerrr	�from_rfc3339�s2
��
�
�z$DatetimeWithNanoseconds.from_rfc3339cCsP|jdur|n|jtjjd�}|t}t|���}|jp |j	d}t
j||d�S)z�Return a timestamp message.

        Returns:
            (:class:`~google.protobuf.timestamp_pb2.Timestamp`): Timestamp message
        Nrr)�secondsr)rr
rrBrCrr;�
total_secondsrrr�	Timestamp)r"r �deltarJrrrr	�timestamp_pb�s
��z$DatetimeWithNanoseconds.timestamp_pbc
Cs@t|jd�}t|�}||j|j|j|j|j|j|j	t
jjd�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��.Ar3)
r;rJr
r<r=r>r?r@rArrrBrC)rrDrrFrrr	�from_timestamp_pb�s�z)DatetimeWithNanoseconds.from_timestamp_pb)�__name__�
__module__�__qualname__�__doc__�	__slots__rr
�propertyrr0�classmethodrIrNrO�
__classcell__rrr'r	rLs"

(r)T)rS�calendarr�re�google.protobufr�
fromtimestamprBrCrrr/�compile�VERBOSEr4r
rrrrrr	�<module>s
�