Skip to content

Parsing ISO 8601 datetimes without hyphens, colons #867

Open
@dmalan

Description

@dmalan

We noticed that ISO 8601 datetimes without hyphens or colons don't seem to be parsable, even though I don't think they're required? Cf. https://en.wikipedia.org/wiki/ISO_8601#Dates, https://en.wikipedia.org/wiki/ISO_8601#Times.

E.g.:

>>> import datetime
>>> str(dateparser.parse("2021-01-01T00:00:00Z"))
'2021-01-01 00:00:00+00:00'
>>> str(dateparser.parse("20210101T000000Z"))
'None'

We currently work around such using isodate, with

import dateparser
import isodate

try:
    dt = isodate.parse_datetime(s)
except (isodate.isoerror.ISO8601Error, ValueError):
    dt = dateparser.parse(s)

but weren't sure whether that was intended?

That question aside, many thanks for the wonderfully handy library!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions