
    [j                    p    d Z ddlmZ ddlZddlZddlmZmZ ddlm	Z	m
Z
 ddlmZ dZ G d d	          ZdS )
z3Tools for representing MongoDB internal Timestamps.    )annotationsN)AnyUnion)_getstate_slots_setstate_slots)utcl        c                      e Zd ZdZdZeZeZdZ	dd
Z
edd            Zedd            ZddZddZddZddZddZddZddZddZd dZdS )!	Timestampz.MongoDB internal timestamps used in the opLog.)__time__inc   timeUnion[datetime.datetime, int]incintreturnNonec                   t          |t          j                  rN|                                }|||z
  }t          t	          j        |                                                    }t          |t                    st          d          t          |t                    st          d          d|cxk    rt          k     sn t          d          d|cxk    rt          k     sn t          d          || _
        || _        dS )a  Create a new :class:`Timestamp`.

        This class is only for use with the MongoDB opLog. If you need
        to store a regular timestamp, please use a
        :class:`~datetime.datetime`.

        Raises :class:`TypeError` if `time` is not an instance of
        :class: `int` or :class:`~datetime.datetime`, or `inc` is not
        an instance of :class:`int`. Raises :class:`ValueError` if
        `time` or `inc` is not in [0, 2**32).

        :Parameters:
          - `time`: time in seconds since epoch UTC, or a naive UTC
            :class:`~datetime.datetime`, or an aware
            :class:`~datetime.datetime`
          - `inc`: the incrementing counter
        Nztime must be an instance of intzinc must be an instance of intr   z$time must be contained in [0, 2**32)z#inc must be contained in [0, 2**32))
isinstancedatetime	utcoffsetr   calendartimegm	timetuple	TypeError
UPPERBOUND
ValueError_Timestamp__time_Timestamp__inc)selfr   r   offsets       R/var/www/app.qaans.com/backend/venv/lib/python3.11/site-packages/bson/timestamp.py__init__zTimestamp.__init__&   s   $ dH-.. 	:^^%%F!f}xt~~'7'78899D$$$ 	?=>>>#s## 	><===D%%%%:%%%%CDDDC$$$$*$$$$BCCC


    c                    | j         S )z0Get the time portion of this :class:`Timestamp`.)r   r    s    r"   r   zTimestamp.timeI   s     {r$   c                    | j         S )z/Get the inc portion of this :class:`Timestamp`.)r   r&   s    r"   r   zTimestamp.incN   s     zr$   otherr   boolc                z    t          |t                    r | j        |j        k    o| j        |j        k    S t          S N)r   r
   r   r   r   r   NotImplementedr    r(   s     r"   __eq__zTimestamp.__eq__S   s7    eY'' 	";%*,Huy1HH!!r$   c                T    t          | j                  t          | j                  z  S r+   )hashr   r   r&   s    r"   __hash__zTimestamp.__hash__Y   s    DIdh//r$   c                    | |k     S r+    r-   s     r"   __ne__zTimestamp.__ne__\   s    5=  r$   c                v    t          |t                    r| j        | j        f|j        |j        fk     S t          S r+   r   r
   r   r   r,   r-   s     r"   __lt__zTimestamp.__lt___   8    eY'' 	CItx(EJ	+BBBr$   c                v    t          |t                    r| j        | j        f|j        |j        fk    S t          S r+   r6   r-   s     r"   __le__zTimestamp.__le__d   8    eY'' 	DItx(UZ,CCCr$   c                v    t          |t                    r| j        | j        f|j        |j        fk    S t          S r+   r6   r-   s     r"   __gt__zTimestamp.__gt__i   r8   r$   c                v    t          |t                    r| j        | j        f|j        |j        fk    S t          S r+   r6   r-   s     r"   __ge__zTimestamp.__ge__n   r;   r$   strc                (    d| j          d| j         dS )Nz
Timestamp(z, ))r   r   r&   s    r"   __repr__zTimestamp.__repr__s   s    8DK884:8888r$   datetime.datetimec                V    t           j                             | j        t                    S )zReturn a :class:`~datetime.datetime` instance corresponding
        to the time portion of this :class:`Timestamp`.

        The returned datetime's timezone is UTC.
        )r   fromtimestampr   r   r&   s    r"   as_datetimezTimestamp.as_datetimev   s      ..t{C@@@r$   N)r   r   r   r   r   r   )r   r   )r(   r   r   r)   )r   r@   )r   rD   )__name__
__module____qualname____doc__	__slots__r   __getstate__r   __setstate___type_markerr#   propertyr   r   r.   r1   r4   r7   r:   r=   r?   rC   rG   r3   r$   r"   r
   r
      s=       88#I"L"LL! ! ! !F    X    X" " " "0 0 0 0! ! ! !   
   
   
   
9 9 9 9A A A A A Ar$   r
   )rK   
__future__r   r   r   typingr   r   bson._helpersr   r   bson.tz_utilr   r   r
   r3   r$   r"   <module>rU      s    : 9 " " " " " "           : : : : : : : :      
`A `A `A `A `A `A `A `A `A `Ar$   