Skip to content

Implement an ISO parser as fallback - #790

Open
Gallaecio wants to merge 12 commits into
scrapinghub:masterfrom
Gallaecio:360
Open

Gallaecio wants to merge 12 commits into
scrapinghub:masterfrom
Gallaecio:360

Conversation

@Gallaecio

@Gallaecio Gallaecio commented Sep 22, 2020 •

Copy link
Copy Markdown
Contributor

Fixes #867, fixes #939.

Adds an iso parser, enabled by default, for complete ISO 8601 dates, optionally with a time, in both the extended (2021-06-29T12:30:45Z) and basic (20210629T123045Z) formats. Fractional seconds accept both . and ,, and time zones go through the same handling as other parsers, so TIMEZONE, TO_TIMEZONE and RETURN_AS_TIMEZONE_AWARE apply.

It is locale-agnostic, so it runs after all locale parsers, regardless of its position in PARSERS. That means no-spaces-time, if enabled, still wins for strings like 20210101, and gets them wrong.

It also parses the date --iso-8601=ns output from #914, which overlaps with #1467. date --iso-8601=hours still does not parse, since times without minutes are not supported.

Not implemented: years (2020, +00002020), months (2020-01), weeks (2020-W01), ordinal dates (2020-094), 24:00:00, times without dates or without minutes, decimal minutes, and ±hh offsets. I think it makes sense to implement those separately, based on user demand.

@codspeed

codspeed Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 11 untouched benchmarks


Comparing Gallaecio:360 (eab2d1f) with master (ce8c439)

Open in CodSpeed

@codecov

codecov Bot commented Sep 29, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 99.22%. Comparing base (ce8c439) to head (eab2d1f).

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #790   +/-   ##
=======================================
  Coverage   99.22%   99.22%           
=======================================
  Files         239      239           
  Lines        4256     4284   +28     
=======================================
+ Hits         4223     4251   +28     
  Misses         33       33           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@AdrianAtZyte
AdrianAtZyte marked this pull request as ready for review September 29, 2026 10:38

@serhii73 serhii73 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not approving yet. Please check these:

  • dictionary.py (around line 512): with NORMALIZE=True, the normalisation seems to drop merged meanings for every locale.
  • The ISO parser returns period time when RETURN_TIME_AS_PERIOD is off. Is that intended?
  • Bare YYYYMMDD strings now parse inside search_dates chunks. Is that intended?
    The branch also conflicts with master.

This branch has not been deployed

No deployments
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

Successfully merging this pull request may close these issues.

ISO 8601 YYYYMMDD format Parsing ISO 8601 datetimes without hyphens, colons

3 participants