Switched to different datetime formatting in JSON.

We now use the same format as the Pillar API.
This commit is contained in:
2016-11-07 10:55:49 +01:00
parent fe2c36328a
commit ea33d69a8e
2 changed files with 4 additions and 2 deletions

View File

@@ -22,6 +22,8 @@ else:
string_type = basestring
text_type = unicode
JSON_DATE_FORMAT = '%a, %d %b %Y %H:%M:%S GMT'
class PillarJSONEncoder(json.JSONEncoder):
"""JSON encoder with support for Pillar resources."""
@@ -31,7 +33,7 @@ class PillarJSONEncoder(json.JSONEncoder):
from .resource import Resource
if isinstance(obj, datetime.datetime):
return obj.isoformat(' ')
return obj.strftime(JSON_DATE_FORMAT)
if isinstance(obj, Resource):
return obj.to_dict()