-
-
Notifications
You must be signed in to change notification settings - Fork 32.1k
gh-84823: Improve doctrings for datetime parsing methods #20677
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
Open
edison12a
wants to merge
5
commits into
python:main
Choose a base branch
from
edison12a:bpo-40643
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
91ebaba
improve doctrings for datetime parsing methods
ab411af
Merge branch 'main' into bpo-40643
taleinat 27f5a98
further improve doc-strings, add to datetime.datetime and add to _dat…
taleinat ad4a503
Merge branch 'main' into bpo-40643
edison12a 601f012
Merge branch 'main' into bpo-40643
AlexWaygood File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
2 changes: 2 additions & 0 deletions
2
Misc/NEWS.d/next/Documentation/2020-06-06-15-25-35.bpo-36783.RVoyHF.rst
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
Improve docstring of :class:`datetime` methods :func:`strftime` and | ||
:func:`strptime`. Enhanced by Edison Abahurire. |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3591,7 +3591,21 @@ static PyMethodDef date_methods[] = { | |
PyDoc_STR("Return ctime() style string.")}, | ||
|
||
{"strftime", _PyCFunction_CAST(date_strftime), METH_VARARGS | METH_KEYWORDS, | ||
PyDoc_STR("format -> strftime() style string.")}, | ||
PyDoc_STR( | ||
"Convert to a string in the given format via time.strftime().\n\n" | ||
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. Same here as well. |
||
"Formatting directives referring to hours, minutes or seconds\n" | ||
"will use zero.\n\n" | ||
"Commonly used formatting directives:\n" | ||
" %Y Year with century as a decimal number.\n" | ||
" %m Month as a decimal number [01,12].\n" | ||
" %d Day of the month as a decimal number [01,31].\n" | ||
" %a Locale's abbreviated weekday name.\n" | ||
" %A Locale's full weekday name.\n" | ||
" %b Locale's abbreviated month name.\n" | ||
" %B Locale's full month name.\n" | ||
" %c Locale's appropriate date and time representation.\n\n" | ||
"For a complete list and detailed descriptions of formatting\n" | ||
"directives, see the library reference manual.")}, | ||
|
||
{"__format__", (PyCFunction)date_format, METH_VARARGS, | ||
PyDoc_STR("Formats self with strftime.")}, | ||
|
@@ -4745,7 +4759,20 @@ static PyMethodDef time_methods[] = { | |
"'milliseconds' and 'microseconds'.\n")}, | ||
|
||
{"strftime", _PyCFunction_CAST(time_strftime), METH_VARARGS | METH_KEYWORDS, | ||
PyDoc_STR("format -> strftime() style string.")}, | ||
PyDoc_STR( | ||
"Convert to a string in the given format via time.strftime().\n\n" | ||
"Formatting directives referring to years will use 1900, and\n" | ||
"those referring to months or days will use 1.\n\n" | ||
"Commonly used formatting directives:\n" | ||
" %H Hour (24-hour clock) as a decimal number [00,23].\n" | ||
" %M Minute as a decimal number [00,59].\n" | ||
" %S Second as a decimal number [00,61].\n" | ||
" %z Time zone offset from UTC.\n" | ||
" %c Locale's appropriate date and time representation.\n" | ||
" %I Hour (12-hour clock) as a decimal number [01,12].\n" | ||
" %p Locale's equivalent of either AM or PM.\n\n" | ||
"For a complete list and detailed descriptions of formatting\n" | ||
"directives, see the library reference manual.")}, | ||
|
||
{"__format__", (PyCFunction)date_format, METH_VARARGS, | ||
PyDoc_STR("Formats self with strftime.")}, | ||
|
@@ -6572,6 +6599,27 @@ static PyMethodDef datetime_methods[] = { | |
{"ctime", (PyCFunction)datetime_ctime, METH_NOARGS, | ||
PyDoc_STR("Return ctime() style string.")}, | ||
|
||
{"strftime", (PyCFunction)(void(*)(void))date_strftime, METH_VARARGS | METH_KEYWORDS, | ||
PyDoc_STR( | ||
"Convert to a string in the given format via time.strftime().\n\n" | ||
"Commonly used formatting directives:\n" | ||
" %Y Year with century as a decimal number.\n" | ||
" %m Month as a decimal number [01,12].\n" | ||
" %d Day of the month as a decimal number [01,31].\n" | ||
" %H Hour (24-hour clock) as a decimal number [00,23].\n" | ||
" %M Minute as a decimal number [00,59].\n" | ||
" %S Second as a decimal number [00,61].\n" | ||
" %z Time zone offset from UTC.\n" | ||
" %a Locale's abbreviated weekday name.\n" | ||
" %A Locale's full weekday name.\n" | ||
" %b Locale's abbreviated month name.\n" | ||
" %B Locale's full month name.\n" | ||
" %c Locale's appropriate date and time representation.\n" | ||
" %I Hour (12-hour clock) as a decimal number [01,12].\n" | ||
" %p Locale's equivalent of either AM or PM.\n\n" | ||
"For a complete list and detailed descriptions of formatting\n" | ||
"directives, see the library reference manual.")}, | ||
|
||
{"timetuple", (PyCFunction)datetime_timetuple, METH_NOARGS, | ||
PyDoc_STR("Return time tuple, compatible with time.localtime().")}, | ||
|
||
|
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think these aren't supposed to be
time.strftime()
, I think we want to directly reference:manpage:`strftime(3)`
. Or at leaststrftime(3)
(I guess these docstrings aren't destined for Sphinx, so probably juststrftime(3)
is most appropriate)