
    nh                    h    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y)
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y)	Timestampz.MongoDB internal timestamps used in the opLog.)__time__inc   c                   t        |t        j                        rC|j                         }|||z
  }t        t	        j
                  |j                                     }t        |t              st        dt        |             t        |t              st        dt        |             d|cxk  rt        k  st        d       t        d      d|cxk  rt        k  st        d       t        d      || _        || _        y)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).

        :param time: time in seconds since epoch UTC, or a naive UTC
            :class:`~datetime.datetime`, or an aware
            :class:`~datetime.datetime`
        :param inc: the incrementing counter
        Nz%time must be an instance of int, not z$inc must be an instance of int, not r   z$time must be contained in [0, 2**32)z#inc must be contained in [0, 2**32))
isinstancedatetime	utcoffsetintcalendartimegm	timetuple	TypeErrortype
UPPERBOUND
ValueError_Timestamp__time_Timestamp__inc)selftimeincoffsets       t/var/www/html/SchoolMeal/SchoolMeal/pds_admin_SchoolMeal/Backend/venv/lib/python3.12/site-packages/bson/timestamp.py__init__zTimestamp.__init__&   s    " dH--.^^%F!f}xt~~'789D$$CDJ<PQQ#s#B49+NOOD%:%CDD &CDDC$*$BCC %BCC
    c                    | j                   S )z0Get the time portion of this :class:`Timestamp`.)r   r   s    r    r   zTimestamp.timeH   s     {{r"   c                    | j                   S )z/Get the inc portion of this :class:`Timestamp`.)r   r$   s    r    r   zTimestamp.incM   s     zzr"   c                    t        |t              r4| j                  |j                  k(  xr | j                  |j
                  k(  S t        S N)r   r
   r   r   r   r   NotImplementedr   others     r    __eq__zTimestamp.__eq__R   s7    eY';;%**,Huyy1HH!!r"   c                X    t        | j                        t        | j                        z  S r'   )hashr   r   r$   s    r    __hash__zTimestamp.__hash__X   s    DIIdhh//r"   c                    | |k(   S r'    r)   s     r    __ne__zTimestamp.__ne__[   s    5=  r"   c                    t        |t              r1| j                  | j                  f|j                  |j                  fk  S t        S r'   r   r
   r   r   r(   r)   s     r    __lt__zTimestamp.__lt__^   7    eY'IItxx(EJJ		+BBBr"   c                    t        |t              r1| j                  | j                  f|j                  |j                  fk  S t        S r'   r3   r)   s     r    __le__zTimestamp.__le__c   7    eY'IItxx(UZZ,CCCr"   c                    t        |t              r1| j                  | j                  f|j                  |j                  fkD  S t        S r'   r3   r)   s     r    __gt__zTimestamp.__gt__h   r5   r"   c                    t        |t              r1| j                  | j                  f|j                  |j                  fk\  S t        S r'   r3   r)   s     r    __ge__zTimestamp.__ge__m   r8   r"   c                <    d| j                    d| j                   dS )Nz
Timestamp(z, ))r   r   r$   s    r    __repr__zTimestamp.__repr__r   s    DKK=4::,a88r"   c                ^    t         j                   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_datetimeu   s!       ..t{{C@@r"   N)r   zUnion[datetime.datetime, int]r   r   returnNone)rC   r   )r*   r   rC   bool)rC   str)rC   zdatetime.datetime)__name__
__module____qualname____doc__	__slots__r   __getstate__r   __setstate___type_markerr!   propertyr   r   r+   r.   r1   r4   r7   r:   r<   r?   rB   r0   r"   r    r
   r
      su    8#I"L"LL D    "0!



9Ar"   r
   )rJ   
__future__r   r   r   typingr   r   bson._helpersr   r   bson.tz_utilr   r   r
   r0   r"   r    <module>rT      s/    : "    : 
_A _Ar"   