Compare commits
1 Commits
Author | SHA1 | Date |
---|---|---|
Raphaël Vinot | f3b15335d5 |
|
@ -11,9 +11,9 @@ import json
|
||||||
class DatetimeEncoder(json.JSONEncoder):
|
class DatetimeEncoder(json.JSONEncoder):
|
||||||
def default(self, obj):
|
def default(self, obj):
|
||||||
if isinstance(obj, datetime):
|
if isinstance(obj, datetime):
|
||||||
return obj.isoformat(' ')
|
return obj.strftime('%Y-%m-%d %H:%M:%S')
|
||||||
elif isinstance(obj, date):
|
elif isinstance(obj, date):
|
||||||
return obj.isoformat()
|
return obj.strftime('%Y-%m-%d')
|
||||||
# Let the base class default method raise the TypeError
|
# Let the base class default method raise the TypeError
|
||||||
return json.JSONEncoder.default(self, obj)
|
return json.JSONEncoder.default(self, obj)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue