From 4c775517b92b32ba9dbbaf3d4d6e7720341caafe Mon Sep 17 00:00:00 2001 From: leigh-mil Date: Fri, 1 Feb 2019 11:12:54 -0500 Subject: [PATCH] Prevent python datetime from converting to Javascript datetime before json encoding. Previously the conversion from python to Javascript datetime objects was adding timezone information, which was causing the date to render incorrectly because the users timezone was different than the encoded time zone. --- atst/utils/json.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/atst/utils/json.py b/atst/utils/json.py index a489fcaa..4ce7bd8d 100644 --- a/atst/utils/json.py +++ b/atst/utils/json.py @@ -1,4 +1,5 @@ from flask.json import JSONEncoder +from datetime import date from atst.models.attachment import Attachment @@ -6,4 +7,6 @@ class CustomJSONEncoder(JSONEncoder): def default(self, obj): if isinstance(obj, Attachment): return obj.filename + if isinstance(obj, date): + return obj.strftime("%Y-%m-%d") return JSONEncoder.default(self, obj)