fhdZddlmZddlZddlZddlmZmZddlm Z m Z ddl m Z dZ Gdd Zy) z3Tools for representing MongoDB internal Timestamps.) annotationsN)AnyUnion)_getstate_slots_setstate_slots)utclceZdZdZdZeZeZdZ ddZ e ddZ e ddZ ddZddZdd Zdd Zdd Zdd Zdd ZddZddZy) Timestampz.MongoDB internal timestamps used in the opLog.)__time__incct|tjrC|j}|||z }tt j |j }t|ts tdt|ts tdd|cxkrtkstdtdd|cxkrtkstdtd||_ ||_ y)aCreate 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 Nztime must be an instance of intzinc must be an instance of intrz$time must be contained in [0, 2**32)z#inc must be contained in [0, 2**32)) isinstancedatetime utcoffsetintcalendartimegm timetuple TypeError UPPERBOUND ValueError_Timestamp__time_Timestamp__inc)selftimeincoffsets W/var/lib/jenkins/workspace/mettalog/venv/lib/python3.12/site-packages/bson/timestamp.py__init__zTimestamp.__init__&s" dH-- .^^%F!f}xt~~'789D$$=> >#s#<= =D%:%CD D&CD DC$*$BC C%BC C  c|jS)z0Get the time portion of this :class:`Timestamp`.)rrs rrzTimestamp.timeHs{{r!c|jS)z/Get the inc portion of this :class:`Timestamp`.)rr#s rrz Timestamp.incMszzr!ct|tr4|j|jk(xr|j|j k(St SN)rr rrrrNotImplementedrothers r__eq__zTimestamp.__eq__Rs7 eY ';;%**,Huyy1H H! !r!cXt|jt|jz Sr&)hashrrr#s r__hash__zTimestamp.__hash__XsDIIdhh//r!c||k( Sr&r(s r__ne__zTimestamp.__ne__[s5=  r!ct|tr1|j|jf|j|jfkStSr&rr rrr'r(s r__lt__zTimestamp.__lt__^7 eY 'IItxx(EJJ +BB Br!ct|tr1|j|jf|j|jfkStSr&r2r(s r__le__zTimestamp.__le__c7 eY 'IItxx(UZZ,CC Cr!ct|tr1|j|jf|j|jfkDStSr&r2r(s r__gt__zTimestamp.__gt__hr4r!ct|tr1|j|jf|j|jfk\StSr&r2r(s r__ge__zTimestamp.__ge__mr7r!c<d|jd|jdS)Nz Timestamp(z, ))rrr#s r__repr__zTimestamp.__repr__rsDKK=4::,a88r!c^tjj|jtS)zReturn a :class:`~datetime.datetime` instance corresponding to the time portion of this :class:`Timestamp`. The returned datetime's timezone is UTC. )r fromtimestamprrr#s r as_datetimezTimestamp.as_datetimeus!   ..t{{C@@r!N)rzUnion[datetime.datetime, int]rrreturnNone)rBr)r)rrBbool)rBstr)rBzdatetime.datetime)__name__ __module__ __qualname____doc__ __slots__r __getstate__r __setstate__ _type_markerr propertyrrr*r-r0r3r6r9r;r>rAr/r!rr r su8#I"L"LL D" 0!    9Ar!r )rI __future__rrrtypingrr bson._helpersrr bson.tz_utilrrr r/r!rrSs/:":  _A_Ar!