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

Default JSON encoder handles datetime.date objects. #944

Closed
wants to merge 2 commits into from

Conversation

jfinkels
Copy link
Contributor

@jfinkels jfinkels commented Jan 8, 2014

Flask's default JSON encoder handles only datetime.datetime objects (via Werkzeug's http_date function). It should also handle datetime.date objects, a common data type that occurs in JSON used to represent dates in backend models.

@chason
Copy link

chason commented Jan 8, 2014

Should this be a fix in Werkzeug's http_date function instead of here?

@jfinkels
Copy link
Contributor Author

jfinkels commented Jan 8, 2014

In werkzeug, the function is used specifically for the HTTP header Date, which expects a specific format (in Python terms, it expects a datetime string formatted in a particular way). When returning a JSON response, no specific format for a date object is expected, so I think this should be a feature handled by Flask, not by werkzeug.

@mitsuhiko
Copy link
Contributor

Date objects are dangerous because they don't contain any timezone information. I'm not going to land a change like this unless someone has a really good explanation of why it's necessary :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants