-
-
Notifications
You must be signed in to change notification settings - Fork 34.5k
gh-140715: Add %t and %n format codes support to strptime() #144896
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 22 commits
43c8345
d838236
a31ad12
669870a
d77ebf7
fcc03cf
5193157
edfed51
16195db
7301962
b753ea6
9b29dbb
d199d0b
dac5692
e9927fb
c674612
3a26205
f709b80
924b7cf
ed87c7d
9541826
2f91a57
608c638
4a4d722
4080b03
bbe7d2e
ab9d41a
4a312ab
4c31a92
3d7c3c7
d6ca685
4e366cb
9f5a37e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2207,6 +2207,19 @@ def test_strptime_D_format(self): | |
| self.theclass.strptime(test_date, "%m/%d/%y") | ||
| ) | ||
|
|
||
| def test_strptime_n_and_t_format(self): | ||
| year, month, day = 2026, 2, 20 | ||
| whitespaces = ('', ' ', '\t', '\r', '\v', '\n', '\f') | ||
| for fd in ('n', 't'): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to also test
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it make sense to add whitespace to the table in the docs? (It already worked before, but AFAIK wasn't documented/tested.)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Commit d6ca685 added The final test for each whitespace format directive is ' I'm all for improved documentation, could you clarify what you are envisioning? The whitespace format directives (
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (By pattern I meant In docs, I meant adding entries for space and tab, in addition to the percent directives, to document that |
||
| for ws in (*whitespaces, ''.join(whitespaces)): | ||
| with self.subTest(format_directive=fd, whitespace=ws): | ||
| self.assertEqual( | ||
| self.theclass.strptime( | ||
| f"{year:04d}{ws}{month:02d}{ws}{day:02d}", | ||
| f"%Y%{fd}%m%{fd}%d" | ||
|
jyalim marked this conversation as resolved.
Outdated
|
||
| ), | ||
| self.theclass(year, month, day) | ||
| ) | ||
|
|
||
|
StanFromIreland marked this conversation as resolved.
|
||
| ############################################################################# | ||
| # datetime tests | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Add ``'%n'`` and ``'%t'`` support to :meth:`~datetime.datetime.strptime`. | ||
|
jyalim marked this conversation as resolved.
Outdated
|
||
Uh oh!
There was an error while loading. Please reload this page.