|
Server : LiteSpeed System : Linux server51.dnsbootclub.com 4.18.0-553.62.1.lve.el8.x86_64 #1 SMP Mon Jul 21 17:50:35 UTC 2025 x86_64 User : nandedex ( 1060) PHP Version : 8.1.33 Disable Function : NONE Directory : /opt/cppython/lib/python3.8/site-packages/proto/marshal/rules/__pycache__/ |
U
O��g? � @ sl d dl m Z d dl mZ d dl mZ d dlmZ d dlmZ d dlmZmZ G dd� d�Z G d d
� d
�Z
dS )� )�datetime)� timedelta)�timezone)�duration_pb2)�
timestamp_pb2)�datetime_helpers�utilsc @ s8 e Zd ZdZdd�eejd�dd�Zej d�dd �Z
dS )
�
TimestampRulea& A marshal between Python datetimes and protobuf timestamps.
Note: Python datetimes are less precise than protobuf datetimes
(microsecond vs. nanosecond level precision). If nanosecond-level
precision matters, it is recommended to interact with the internal
proto directly.
N��absent�r �returnc C s$ t |tj�r |rd S tj�|�S |S )N)�
isinstancer � Timestampr �DatetimeWithNanosecondsZfrom_timestamp_pb��self�valuer � r �F/opt/cppython/lib/python3.8/site-packages/proto/marshal/rules/dates.py� to_python! s
zTimestampRule.to_python�r
c C s` t |tj�r|�� S t |t�r:tjt|�� �|j d d�S t |t
�r\t�� }|j|d� |S |S )N�� ��seconds�nanos�r )r r r Ztimestamp_pbr r r �int� timestamp�microsecond�str�FromJsonString)r r Ztimestamp_valuer r r �to_proto* s
�
zTimestampRule.to_proto)�__name__�
__module__�__qualname__�__doc__�boolr r r r r r"