HEX
Server: LiteSpeed
System: Linux srv146.niagahoster.com 4.18.0-553.30.1.lve.el8.x86_64 #1 SMP Tue Dec 3 01:21:19 UTC 2024 x86_64
User: kodi1989 (1633)
PHP: 8.1.34
Disabled: symlink,shell_exec,exec,popen,system,dl,passthru,escapeshellarg,escapeshellcmd,show_source,pcntl_exec
Upload Files
File: //opt/alt/python37/lib/python3.7/site-packages/proto/__pycache__/datetime_helpers.cpython-37.pyc
B

��f��@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�G/opt/alt/python37/lib/python3.7/site-packages/proto/datetime_helpers.py�_from_microseconds,s
r
TcCs,|s"|jdk	r"|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)rZignore_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.
    )�_nanosecondcOsR|�dd�}|dkr0d|kr$td��|d|d<tjj|f|�|�}|pJd|_|S)N�
nanosecondr�microsecondz1Specify only one of 'microsecond' or 'nanosecond'i�)�pop�	TypeErrorr�__new__r)�cls�args�kw�nanos�instrrr	rUs
zDatetimeWithNanoseconds.__new__csxd|k}d|k}|�dd�}|j}|r2|r2td��|rB|d|d<t�j||�}|rb|jd|_n|rn||_n||_|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.
        rrrz1Specify only one of 'microsecond' or 'nanosecond'i�)rrr�superrrr)�selfrrZms_providedZns_providedZprovided_nsZ
prev_nanosr)�	__class__rr	r`szDatetimeWithNanoseconds.replacecCs|jp|jdS)z Read-only: nanosecond precision.i�)rr)rrrr	r�sz"DatetimeWithNanoseconds.nanosecondcCs<|jdkrt|�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)rrrrr	�rfc3339�s
zDatetimeWithNanoseconds.rfc3339c
Cs�t�|�}|dkr$td�|tj���tj�|�d�t�}|�d�}|dkrPd}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: {}Zno_fractionrrr �
)rr)�_RFC3339_NANOS�match�
ValueErrorr%�patternr�strptime�groupr&�len�int�year�month�day�hour�minute�second�timezone�utc)r�stampZ
with_nanos�bare�fractionrZscalerrr	�from_rfc3339�s*

z$DatetimeWithNanoseconds.from_rfc3339cCsP|jdk	r|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
        N)ri�)�secondsr)rrrr7r8rr0�
total_secondsrrr�	Timestamp)rr�deltar=rrrr	�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��.A)rr)
r0r=r
r1r2r3r4r5r6rrr7r8)rr9rr:rrr	�from_timestamp_pb�sz)DatetimeWithNanoseconds.from_timestamp_pb)�__name__�
__module__�__qualname__�__doc__�	__slots__rr�propertyrr'�classmethodr<rArB�
__classcell__rr)rr	rLs")r)T)rF�calendarr�reZgoogle.protobufr�
fromtimestampr7r8rrr&�compile�VERBOSEr)r
rrrrrr	�<module>s