Skip to content

demozoo/europarse

Repository files navigation

europarse - dateutil.parser, but not broken

Since version 2.5.2, the python-dateutil's parser module has had a rather severe bug (for non-Americans): if you specify the dayfirst=True option to indicate that ambiguous xx/xx/xxxx dates should be interpreted as dd/mm/yyyy, it is no longer able to parse ISO 8601 YYYY-MM-DD dates, treating them as YYYY-DD-MM instead.

It appears that the maintainers consider the dayfirst option to have been a mis-step, and a replacement for it has been coming Real Soon Now for the last 5 years, which isn't much consolation for developers who are quite happy with the principle of dayfirst and just want it to work.

europarse is a fork of the last good version of dateutil.parser, brought up to date with currently-supported versions of Python (3.7 to 3.11).

Installation

pip install europarse

Usage

from europarse.parser import parse

parse("8th nov 2022")
# => datetime.datetime(2022, 11, 8, 0, 0)
parse("08/11/2022")
# => datetime.datetime(2022, 8, 11, 0, 0)
parse("08/11/2022", dayfirst=True)
# => datetime.datetime(2022, 11, 8, 0, 0)

For additional usage notes, see the dateutil docs - just replace dateutil in import lines with europarse.

About

a fork of dateutil.parser that isn't broken

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages