MCPcopy Index your code
hub / github.com/MongoEngine/mongoengine / _convert_from_datetime

Method _convert_from_datetime

mongoengine/fields.py:643–653  ·  view source on GitHub ↗

Convert a `datetime` object to a string representation (which will be stored in MongoDB). This is the reverse function of `_convert_from_string`. >>> a = datetime(2011, 6, 8, 20, 26, 24, 92284) >>> ComplexDateTimeField()._convert_from_datetime(a) '20

(self, val)

Source from the content-addressed store, hash-verified

641 super().__init__(**kwargs)
642
643 def _convert_from_datetime(self, val):
644 """
645 Convert a `datetime` object to a string representation (which will be
646 stored in MongoDB). This is the reverse function of
647 `_convert_from_string`.
648
649 >>> a = datetime(2011, 6, 8, 20, 26, 24, 92284)
650 >>> ComplexDateTimeField()._convert_from_datetime(a)
651 '2011,06,08,20,26,24,092284'
652 """
653 return val.strftime(self.format)
654
655 def _convert_from_string(self, data):
656 """

Callers 3

__set__Method · 0.95
to_mongoMethod · 0.95
prepare_query_valueMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected