timestamp – Tools for representing MongoDB internal Timestamps
Tools for representing MongoDB internal Timestamps.
- class
bson.timestamp.
Timestamp
(time, inc) - Create a new
Timestamp
.
This class is only for use with the MongoDB opLog. If you needto store a regular timestamp, please use adatetime
.
Raises TypeError
if time is not an instance of:class: int or datetime
, or inc is notan instance of int
. Raises ValueError
iftime or inc is not in [0, 2**32).
Parameters:
- time: time in seconds since epoch UTC, or a naive UTC
datetime
, or an awaredatetime
- inc: the incrementing counter
The returned datetime’s timezone is UTC.