This is an archive of the discontinued Mercurial Phabricator instance.

dateutil: correct default for Ymd in parsedate
ClosedPublic

Authored by quark on Nov 25 2019, 3:50 PM.

Details

Summary

The code uses 0 for the default value of Ymd (year, month, and day), which
seems suboptimal. For example, these will fail to parse:

dateutil.parsedate('2000', formats=dateutil.extendeddateformats)
dateutil.parsedate('Jan 2000', formats=dateutil.extendeddateformats)

Fix it by providing sane defaults (1 instead of 0) for year, month, and day.

The suboptimal behavior was introduced by 91bc001a592 (2010-12-29,
"date: fix matching of underspecified date ranges"), which does not seem to
justify the current behavior.

Note end-users should not notice the subtle issue, because there are no formats
in defaultdateformats that allow an explicit year with omitted month, or an
explicit month with omitted day.

Diff Detail

Repository
rHG Mercurial
Lint
Lint Skipped
Unit
Unit Tests Skipped

Event Timeline

quark created this revision.Nov 25 2019, 3:50 PM
pulkit accepted this revision.Nov 26 2019, 9:18 AM
This revision is now accepted and ready to land.Nov 26 2019, 9:18 AM
This revision was automatically updated to reflect the committed changes.