File: //usr/local/CyberCP/lib/python3.10/site-packages/proto/__pycache__/datetime_helpers.cpython-310.pyc
o
�h� � @ sx d Z ddlZddlZddlZddlmZ ej�dejj�Z dZ
dZe�dej
�Zdd� Zdd
d�ZG dd
� 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
c C s t tj| d� 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)�value� r �I/usr/local/CyberCP/lib/python3.10/site-packages/proto/datetime_helpers.py�_from_microseconds, s
r
Tc C s, |s| j dur| 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_zoner r r �_to_rfc33399 s
r c s` e Zd ZdZdZdd� Z� fdd�Zedd� �Zd d
� Z e
dd� �Zd
d� Ze
dd� �Z
� ZS )�DatetimeWithNanosecondszuTrack nanosecond in addition to normal datetime attrs.
Nanosecond can be passed only as a keyword argument.
)�_nanosecondc O sX |� dd�}|dkrd|v rtd��|d |d<