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

Function _encode_datetimems

bson/json_util.py:834–842  ·  view source on GitHub ↗
(obj: Any, json_options: JSONOptions)

Source from the content-addressed store, hash-verified

832
833
834def _encode_datetimems(obj: Any, json_options: JSONOptions) -> dict: # type: ignore[type-arg]
835 if (
836 json_options.datetime_representation == DatetimeRepresentation.ISO8601
837 and 0 <= int(obj) <= _MAX_UTC_MS
838 ):
839 return _encode_datetime(obj.as_datetime(), json_options)
840 elif json_options.datetime_representation == DatetimeRepresentation.LEGACY:
841 return {"$date": int(obj)}
842 return {"$date": {"$numberLong": str(int(obj))}}
843
844
845def _encode_code(obj: Code, json_options: JSONOptions) -> dict: # type: ignore[type-arg]

Callers

nothing calls this directly

Calls 2

_encode_datetimeFunction · 0.70
as_datetimeMethod · 0.45

Tested by

no test coverage detected