Skip to content

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

Open

Description

@skoehler

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().

Activity

  1. Paebbels commented on Feb 23, 2024

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions