Repository navigation
Support short UTC offset timezones - #1340
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1340 +/- ##
=======================================
Coverage 97.11% 97.11%
=======================================
Files 235 235
Lines 2909 2911 +2
=======================================
+ Hits 2825 2827 +2
Misses 84 84 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
serhii73
left a comment
There was a problem hiding this comment.
Thanks for the PR. This now has merge conflicts, and current master already parses bare two-digit offsets: get_timezone_from_tz_string('+08') returns UTC+08:00 and parse('2024-05-01 10:00 +08') gives +08:00 (added in #1475). I'm not merging it as is. If you still need something it doesn't cover, please rebase and add a failing case, otherwise it can be closed as superseded.
Master already parses bare two-digit offsets (scrapinghub#1475), so the get_timezone_from_tz_string change is dropped and only the regression test is kept. Co-Authored-By: Claude Sonnet 5.5 <[email protected]>
serhii73
left a comment
There was a problem hiding this comment.
Merged master into the branch and dropped the get_timezone_from_tz_string change, because #1475 already parses bare two-digit offsets. The PR is now test-only: it pins +08 and -03. Full suite passes (24885 passed). Code review found no correctness issues. Non-blocking: the test could also cover the TIMEZONE setting through parse() and boundary offsets, and could live in tests/test_utils.py.
Summary
Support two-digit UTC offset timezone strings such as
+08and-03when they are passed through timezone settings. These values are produced by Python's timezone APIs on some systems, but currently raiseUnknownTimeZoneErrorwhile equivalent forms likeUTC+08,+0800, and+08:00are accepted.Changes
+HH/-HHtimezone strings to the existingUTC+HHmatching path.Validation
python -m pytest tests/test_short_utc_offsets.py -q->2 passeddateparser.parse(..., settings={"TIMEZONE": "+08"})and"-03"no longer raise.