question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

fields.Date accepts input in non ISO8601 format. This leads to unaccepted behaviour.

See original GitHub issue

The 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:closed
  • Created 5 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

2reactions
dushrcommented, Aug 5, 2018

@sloria Yup, I can do that.

1reaction
dushrcommented, Sep 14, 2018

👍 Will try to get this done by this weeekend

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found