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

parser.isoparse() accepts invalid ISO 8601 timestamps #1341

Open
skoehler opened this issue Feb 23, 2024 · 1 comment
Open

parser.isoparse() accepts invalid ISO 8601 timestamps #1341

skoehler opened this issue Feb 23, 2024 · 1 comment

Comments

@skoehler
Copy link

Here are an example that accepts 6 timestamp string that are all invalid according to ISO 8601:

from dateutil.parser import isoparse

for i in (
"2024-01-17T15:21:00-0800",
"2024-01-17T152100-08:00",
"20240117T15:21:00-08:00",
"2024-01-17T152100-0800",
"20240117T15:21:00-0800",
"20240117T152100-08:00"):
    print(isoparse(i))

The EBNF grammar in ISO 8601 clearly indicates that basic format (date without dashes, time and zone without colons) cannot be mixed with the extended format (date with dashes, time and zone with colons). Yet, any mixture of basic and extended format is accepted by isoparse().

It should be said that only removing a single dash from the date or a single colon from the time is not accepted by isoparse().

@Paebbels
Copy link

The same bug has been reported to Python's stdlib:

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

No branches or pull requests

2 participants