json: always use UTC datetime format (#6927)

This commit is contained in:
Thomas NOËL 2015-04-14 14:51:18 +02:00
parent 3c6b72006f
commit 2ba78294e4
1 changed files with 1 additions and 1 deletions

View File

@ -388,6 +388,6 @@ def indent_xml(elem, level=0):
class JSONEncoder(json.JSONEncoder):
def default(self, obj):
if isinstance(obj, time.struct_time):
return qommon.strftime.strftime('%Y-%m-%dT%H:%M:%S', obj)
return datetime.datetime.utcfromtimestamp(time.mktime(obj)).isoformat() + 'Z'
# Let the base class default method raise the TypeError
return json.JSONEncoder.default(self, obj)