Repository navigation
fix: preserve complete week dates when parsing custom formats - #1381
Conversation
|
139ab61 to
99e022b
Compare
|
Thanks, simplified the condition to the three groups: week, weekday, and year. The regex still consumes The focused tests and full suite pass on macOS and Linux with the new warnings-as-errors configuration (24,380 passed, 4 skipped, 1 xfailed, plus 36 subtests on each platform). |
AdrianAtZyte
left a comment
There was a problem hiding this comment.
Looks good, thanks! Two nits, no need for another round if you would rather not:
- The
if "%U" in fmt or "%W" in fmt or "%V" in fmt:guard is redundant with the first set intersection, so the block can be flat.- I would drop the comment in
strptime.py. It explains why the alternative was not taken, which belongs in the commit message; the code reads fine on its own.
|
Thanks for the approval, @AdrianAtZyte! @serhii73 when you have a moment, could you take a look and approve the workflow runs? They're still waiting on maintainer approval, so the full test suite hasn't run on this PR yet. Happy to apply Adrian's two nits here or in a follow-up, whichever you prefer. |
Codecov Reportβ
All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #1381 +/- ##
=======================================
Coverage 97.18% 97.19%
=======================================
Files 236 236
Lines 3057 3063 +6
=======================================
+ Hits 2971 2977 +6
Misses 86 86 β View full report in Codecov by Harness. π New features to boost your workflow:
|
|
Thanks! |
Summary
Custom formats containing a year, week number, and weekday are complete dates, but the missing-field detection treats them as missing their month and day. For example,
01.24-1with%W.%y-%wis overwritten with date preferences instead of returning 2024-01-01. ISO week dates also have their computed year replaced because%Gis not recognized.Preserve the complete date returned by
strptime, including calendar years that differ from the ISO week year. Week 0 can reach the previous year and needscalendar.isleap; the private calendar currently loads_strptimeby mistake. Copy the standard calendar namespace before rebinding the English names, without re-executing calendar or changing its global constants.The missing-field check uses a flat year/week/weekday condition after
strptimehas validated the format.The regressions cover week numbering conventions, year boundaries, leap days, weekday names, date preferences, escaped directives, incomplete formats, invalid ISO dates, and global calendar isolation.
Fixes #1242.
Validation