gh-140715: Add %C format code support to strptime()#145955
Open
jyalim wants to merge 7 commits intopython:mainfrom
Open
gh-140715: Add %C format code support to strptime()#145955jyalim wants to merge 7 commits intopython:mainfrom
jyalim wants to merge 7 commits intopython:mainfrom
Conversation
5 tasks
jyalim
commented
Mar 15, 2026
| 'Op': mapping['p'], | ||
| 'W': mapping['U'].replace('U', 'W'), | ||
| }) | ||
| mapping['W'] = mapping['U'].replace('U', 'W') |
Contributor
Author
There was a problem hiding this comment.
I also brought this dictionary update into the update above it for greater stylistic consistency.
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.
Incrementally builds C99+ datetime support with addition of
%C. Also adds tests (for%Cand for%ywith%C) and updates documentation.Continued effort from PR: #140647, #144819, #144896.
Documentation drops (0) footnote and notes that zero-padded century numbers are optional (for centuries 0 to 99).
Passed all tests.
Passed patchcheck.
Issue: #140715
Note, this feature runs against
datetime.MINYEAR=1; C99 strptime reads century 0 as year 0. Initial PR proposes settingyear=1forcentury=0, otherwise the object's year is calculated asyear=100*century.str*timeto C11 format codes #140715📚 Documentation preview 📚: https://cpython-previews--145955.org.readthedocs.build/