Repository navigation
Fix timezone parser ignoring Unicode dash-like UTC offset characters - #1474
Merged
AdrianAtZyte merged 2 commits intoSep 29, 2026
Conversation
Sources like Wikipedia's UTC offset list typographically render negative offsets with Unicode dash characters (e.g. U+2212 MINUS SIGN) instead of ASCII hyphen-minus, which the UTC/GMT offset regexes never matched, so the offset was silently dropped (fixes scrapinghub#1126). Normalize the full set of Unicode Dash Characters (per the Unicode Standard's Dash property table) to ASCII hyphen-minus in sanitize_date(), mirroring the existing apostrophe-look-alike normalization. Co-Authored-By: Claude Sonnet 5 <[email protected]>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1474 +/- ##
=======================================
Coverage 97.21% 97.21%
=======================================
Files 236 236
Lines 3090 3093 +3
=======================================
+ Hits 3004 3007 +3
Misses 86 86 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Some recently-added dash characters (e.g. Garay Hyphen, Yezidi
Hyphenation Mark, Oblique Hyphen) aren't in the unicodedata name
tables bundled with older Python versions, so \N{...} escapes for
them raised a SyntaxError on Python 3.10 in CI. \u/\U hex escapes
only need the codepoint, not a name lookup, so they work regardless
of the interpreter's Unicode database version.
Co-Authored-By: Claude Sonnet 5 <[email protected]>
Comment on lines
+40
to
+44
| # Unicode Dash Characters, per the "Dash" property table in the Unicode Standard | ||
| # (https://www.unicode.org/versions/latest/core-spec/chapter-6/#G9697), excluding | ||
| # U+002D HYPHEN-MINUS itself. Written as \u/\U escapes rather than \N{...} names | ||
| # since some of these (e.g. Garay Hyphen, Yezidi Hyphenation Mark) are recent | ||
| # Unicode additions not present in the unicodedata name tables of older Pythons. |
Member
There was a problem hiding this comment.
This comment could just be the URL 🙂
AdrianAtZyte
approved these changes
Sep 29, 2026
Merged
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
dateparser.parse("jan 15th UTC−06:00")(using U+2212 MINUS SIGN, as Wikipedia's List of UTC offsets does) silently dropped the offset instead of parsing it, because the UTC/GMT offset regexes only match the ASCII hyphen-minus-.sanitize_date(), mirroring the existing apostrophe-look-alike normalization already in that function.UTC+01:00) are unaffected — they already used, and still use, plain ASCII+.Test plan
TestSanitizeDate.test_sanitize_date_dash_look_alikes(unit test onsanitize_date, iterating the full dash character list).TestUnicodeDashOffsetsintests/test_timezone_parser.py(end-to-enddateparser.parse()test reproducing the issue's example plus other dash variants).pytest tests/(24274 passed, 6 skipped, 1 xfailed).ruff check/ruff format --checkclean on changed files.🤖 Generated with Claude Code