MCPcopy Index your code
hub / github.com/mongodb/mongo-python-driver / as_datetime

Method as_datetime

bson/datetime_ms.py:100–110  ·  view source on GitHub ↗

Create a Python :class:`~datetime.datetime` from this DatetimeMS object. :param codec_options: A CodecOptions instance for specifying how the resulting DatetimeMS object will be formatted using ``tz_aware`` and ``tz_info``. Defaults to :const:`~bson.codec

(
        self, codec_options: CodecOptions[Any] = DEFAULT_CODEC_OPTIONS
    )

Source from the content-addressed store, hash-verified

98 _type_marker = 9
99
100 def as_datetime(
101 self, codec_options: CodecOptions[Any] = DEFAULT_CODEC_OPTIONS
102 ) -> datetime.datetime:
103 """Create a Python :class:`~datetime.datetime` from this DatetimeMS object.
104
105 :param codec_options: A CodecOptions instance for specifying how the
106 resulting DatetimeMS object will be formatted using ``tz_aware``
107 and ``tz_info``. Defaults to
108 :const:`~bson.codec_options.DEFAULT_CODEC_OPTIONS`.
109 """
110 return cast(datetime.datetime, _millis_to_datetime(self._value, codec_options))
111
112 def __int__(self) -> int:
113 return self._value

Callers 1

Calls 1

_millis_to_datetimeFunction · 0.85

Tested by 1