Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Formalize datetime output format #81

Closed
newsch opened this issue Jul 20, 2017 · 0 comments · Fixed by #82
Closed

Formalize datetime output format #81

newsch opened this issue Jul 20, 2017 · 0 comments · Fixed by #82
Assignees
Labels
enhancement New and enhanced functional
Milestone

Comments

@newsch
Copy link
Collaborator

newsch commented Jul 20, 2017

Currently ABE outputs datetimes in this format: "Sun, 06 Aug 2017 09:00:00 GMT".

It would be better to use a standard like ISO8601: "2017-08-06T09:00:00". Futureboard was having trouble parsing that specific string with their date library, and it makes sense to have control over the output of the API.

This could be done by extending Flask's JSONEncoder like so:

from flask.json import JSONEncoder

class CustomJSONEncoder(JSONEncoder):

    def default(self, obj):
        if isinstance(obj, datetime):
            return obj.isoformat()
        else:
            return JSONEncoder.default(self, obj)


app = Flask(__name__)
app.json_encoder = CustomJSONEncoder
@newsch newsch added the enhancement New and enhanced functional label Jul 20, 2017
@newsch newsch added this to the Shipping v1.0 milestone Jul 20, 2017
@newsch newsch self-assigned this Jul 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New and enhanced functional
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant