Skip to content

Fix non-padded month parsing for ISO-8601. Also added test.#287

Open
tersers wants to merge 2 commits into
python-pendulum:masterfrom
tersers:Fix-286
Open

Fix non-padded month parsing for ISO-8601. Also added test.#287
tersers wants to merge 2 commits into
python-pendulum:masterfrom
tersers:Fix-286

Conversation

@tersers

@tersers tersers commented Oct 18, 2018

Copy link
Copy Markdown

No description provided.

@tersers

tersers commented Oct 18, 2018

Copy link
Copy Markdown
Author

Weird, these ran fine on my machine. Will fix!

@tersers

tersers commented Oct 20, 2018

Copy link
Copy Markdown
Author

Fixes #286

I noticed a documentation issue in the parsing/__init__.py's COMMON regex, where it mentions support for dash-separated dates but does not implement it in the regex. This was corrected and elaborated on with other examples, and the regex was changed to support dashes.

@sdispater

Copy link
Copy Markdown
Collaborator

I am pretty sure the ISO-8601 spec does not allow non-padded months: https://en.wikipedia.org/wiki/ISO_8601#Calendar_dates

@tersers

tersers commented Oct 29, 2018

Copy link
Copy Markdown
Author

Agreed, which is why the change is reflected in the common parser rather than the ISO-8601 parser. I understand the user could unwittingly provide an incorrect ISO-8601 string which would fail to be parsed by the ISO-8601 parser but processed just fine by the common parser. If there is a mechanism to strictly enforce ISO-8601 parsing then this commit increases the flexibility of the rest of the library without harming ISO-8601 compliance.

As an aside, I notice an unnecessary print in my commit. I'll remove it later tonight.

@jamesmyatt

Copy link
Copy Markdown

How do you know that "2011-8" means August 2011 rather than 8 Jan 2011?

@tersers

tersers commented Oct 31, 2018

Copy link
Copy Markdown
Author

As you would expect, there's no clear distinction between the two. However, there is some freedom since this string is handled by the common parser.

With that said, another question comes to mind: how much flexibility does the common parser have, and is there a way to specify strict ISO-8601 parsinig or common parsing?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants