
    ZTh                         d dl m Z mZ d dlmZmZ d dlZd dlmZ	 dee	ej                  e e
ef   dej                  fdZdee e
eef   de	fdZy)	    )datetimetimezone)UnioncastN)	Timestampargreturnc                    t        | t        j                        r| S t        | t              r| j                  }| j
                  }t        j                  |t        j                        }t        j                  |      }t        t        j                  |t        j                  |d      z         S t        | t              rRt        j                  | t        j                        }t        t        j                  t        j                  |            S t        t        j                  t        j                  |             S )zf
    Converts a variety of time-types to a pandas timestamp which supports nano-second precision.
    )tzns)unit)
isinstancepdr   TimestampPbsecondsnanosr   fromtimestampr   utcr   	Timedeltaint)r   r   r   dttss        [/home/www/backend.miabetepe.com/venv/lib/python3.12/site-packages/sift_py/_internal/time.pyto_timestamp_nanosr      s    
 #r||$
	C	%++		##G=\\"BLL"r||E'E"EFF	C	##CHLL9BLL",,r"233 BLL",,s"344    c                     t               }t        | t              r|j                  |        |S t        | t        t
        f      r&|j                  t        j                  |              |S |j                  t        j                  |              |S )z
    Mainly used for testing at the moment. If using this for non-testing purposes
    should probably make this more robust and support nano-second precision.
    )r   r   r   FromDatetimer   floatr   fromisoformat)r   r   s     r   to_timestamp_pbr        sl     
B#x 
		C#u	&
..s34	
..s34	r   )r   r   typingr   r   pandasr   google.protobuf.timestamp_pb2r   r   strr   r   r   r     r   r   <module>r&      s`    '   B5E+r||XsC"OP 5UWUaUa 50xc589 k r   