timestamp – Tools for representing MongoDB internal Timestamps (original) (raw)

Back to top

View this page

Toggle table of contents sidebar

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 need to store a regular timestamp, please use adatetime.

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

Parameters:

as_datetime()

Return a datetime instance corresponding to the time portion of this Timestamp.

The returned datetime’s timezone is UTC.

Return type:

datetime

property inc_: int_

Get the inc portion of this Timestamp.

property time_: int_

Get the time portion of this Timestamp.