File manager - Edit - /usr/local/CyberPanel/lib/python3.10/site-packages/proto/marshal/rules/__pycache__/dates.cpython-310.pyc
Back
o �h? � @ 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 @ s: e Zd ZdZdd�dedejfdd�Zdej fdd �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��absentr �returnc C s$ t |tj�r|r d S tj�|�S |S )N)� isinstancer � Timestampr �DatetimeWithNanoseconds�from_timestamp_pb��self�valuer � r �O/usr/local/CyberPanel/lib/python3.10/site-packages/proto/marshal/rules/dates.py� to_python! s zTimestampRule.to_pythonc C s` t |tj�r |�� S t |t�rtjt|�� �|j d d�S t |t �r.t�� }|j|d� |S |S )N�� ��seconds�nanos�r )r r r �timestamp_pbr r r �int� timestamp�microsecond�str�FromJsonString)r r �timestamp_valuer r r �to_proto* s � zTimestampRule.to_proto)�__name__� __module__�__qualname__�__doc__�boolr r r r r r# r r r r r s �� � r c @ s8 e Zd ZdZdd�dedefdd�Zdejfdd �Z dS ) �DurationRulea' A marshal between Python timedeltas and protobuf durations. Note: Python timedeltas are less precise than protobuf durations (microsecond vs. nanosecond level precision). If nanosecond-level precision matters, it is recommended to interact with the internal proto directly. Nr r r c C s0 t |tj�rt|jd |jd |jd d�S |S )N�Q r )�daysr �microseconds)r r �Durationr r r r r r r r B s �zDurationRule.to_pythonc C sP t |t�rtj|jd |j |jd d�S t |t�r&t�� }|j|d� |S |S )Nr* r r r ) r r r r- r+ r r, r r! )r r �duration_valuer r r r# K s � zDurationRule.to_proto) r$ r% r&