
    (ph?                     x    S SK J r   S SK Jr  S SK Jr  S SKJr  S SKJr  S SKJrJr   " S S5      r	 " S	 S
5      r
g)    )datetime)	timedelta)timezone)duration_pb2)timestamp_pb2)datetime_helpersutilsc                   h    \ rS rSrSrSS.S\S\R                  4S jjrS\	R                  4S jrS	rg)
TimestampRule   a  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                    [        U[        R                  5      (       a'  U(       a  g [        R                  R                  U5      $ U$ )N)
isinstancer   	Timestampr   DatetimeWithNanosecondsfrom_timestamp_pbselfvaluer   s      L/var/www/html/venv/lib/python3.13/site-packages/proto/marshal/rules/dates.py	to_pythonTimestampRule.to_python!   s9     e]4455#;;MMeTT    c                 v   [        U[        R                  5      (       a  UR                  5       $ [        U[        5      (       a9  [
        R                  " [        UR                  5       5      UR                  S-  S9$ [        U[        5      (       a&  [
        R                  " 5       nUR                  US9  U$ U$ )N  secondsnanosr   )r   r   r   timestamp_pbr   r   r   int	timestampmicrosecondstrFromJsonString)r   r   timestamp_values      r   to_protoTimestampRule.to_proto*   s    e-EEFF%%''eX&& **EOO-.''$.  eS!!+557O***7""r    )__name__
__module____qualname____firstlineno____doc__boolr   r   r   r   r   r)   __static_attributes__r+   r   r   r   r      s9     (, $		1	1!8!8 r   r   c                   T    \ rS rSrSrSS.S\S\4S jjrS\R                  4S jr
S	rg)
DurationRule9   a  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                    [        U[        R                  5      (       a2  [        UR                  S-  UR                  S-  UR
                  S-  S9$ U$ )NQ r   )daysr   microseconds)r   r   Durationr   r   r    r   s      r   r   DurationRule.to_pythonB   sM    e\2233]]e+-"[[D0 
 r   c                    [        U[        5      (       a<  [        R                  " UR                  S-  UR
                  -   UR                  S-  S9$ [        U[        5      (       a&  [        R                  " 5       nUR                  US9  U$ U$ )Nr7   r   r   r!   )	r   r   r   r:   r8   r   r9   r&   r'   )r   r   duration_values      r   r)   DurationRule.to_protoK   s~    eY''((

U*U]]:((4/  eS!!)224N)))6!!r   r+   )r,   r-   r.   r/   r0   r1   r   r   r   r:   r)   r2   r+   r   r   r4   r4   9   s1     26 $ ) 
!6!6 
r   r4   N)r   r   r   google.protobufr   r   protor   r	   r   r4   r+   r   r   <module>rA      s.       ( ) ) B r   