Ensure server always return proper ISO encoded dates with timezone

This commit is contained in:
Lucas Verney 2018-08-02 11:14:38 +02:00
parent bb926abbc4
commit 343143e8e7
1 changed files with 2 additions and 1 deletions

View File

@ -3,6 +3,7 @@
"""
Helpers to implement a JSON API with Bottle.
"""
import arrow
import datetime
import json
import re
@ -18,7 +19,7 @@ class DateAwareJSONEncoder(json.JSONEncoder):
"""
def default(self, o): # pylint: disable=locally-disabled,E0202
if isinstance(o, (datetime.date, datetime.datetime)):
return o.isoformat()
return arrow.get(o).isoformat()
return json.JSONEncoder.default(self, o)