def _serialize(self, value, attr, obj):
        if value is None:
            return None
        self.dateformat = self.dateformat or self.DEFAULT_FORMAT
        format_func = self.DATEFORMAT_SERIALIZATION_FUNCS.get(self.dateformat, None)
        if format_func:
            try:
                return format_func(value, localtime=self.localtime)
            except (__HOLE__, ValueError) as err:
                self.fail('format', input=value)
        else:
            return value.strftime(self.dateformat)
dataset/ETHPy150Open marshmallow-code/marshmallow/marshmallow/fields.py/DateTime._serialize