fields.Date accepts input in non ISO8601 format. This leads to unaccepted behaviour.
See original GitHub issueThe doc of fields.Date
suggests that it accepts only ISO8601 date format.
class Date(Field):
"""ISO8601-formatted date string.
:param kwargs: The same keyword arguments that :class:`Field` receives.
"""
It works with ISO8601 format fine:
In [2]: fields.Date().deserialize('2018-10-08')
Out[2]: datetime.date(2018, 10, 8)
However unfortunately it also works with non ISO8601 formats:
In [3]: fields.Date().deserialize('08-10-2018')
Out[3]: datetime.date(2018, 8, 10)
And in this case it seems like it parses the format as %m-%d-%Y
I feel, it should raise a ValidationError with invalid_date
format incase the input is not in the iso8601 format.
Digging further into the issue I found that DateField uses utils.from_iso_date
; which inturn uses dateutil (if available) parser to parse the date.
I think that util should be modified to use dateutil.parser.isoparse
Issue Analytics
- State:
- Created 5 years ago
- Comments:11 (11 by maintainers)
Top Results From Across the Web
Single data type for imprecise date values, as allowed by ISO ...
ISO 8601 allows date values with reduced precision. '1964', '1964-05', '1964-05-02' are all valid representations of a value, in increasing precision. The ...
Read more >how do I parse an iso 8601 date (with optional milliseconds) to ...
New answer for old question. Rationale: updated tools. Using this free, open source library, one can parse into a std::chrono::time_point<system_clock, ...
Read more >New Issue View does not respect Jira's Advanced Settings ...
We are working to consolidate the different date & datetime formats we currently have on the new issue view, as well as respecting...
Read more >Documentation: 15: 8.5. Date/Time Types - PostgreSQL
Date and time input is accepted in almost any reasonable format, including ISO 8601, SQL -compatible, traditional POSTGRES, and others. For some formats ......
Read more >Date and Time Input / Output - Snowflake Documentation
To determine the input and output formats to use for dates, times, and timestamps, ... If a matching format is found, Snowflake accepts...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@sloria Yup, I can do that.
👍 Will try to get this done by this weeekend