Skip to content

bpo-41867: Include options for timespec in docstrings of isoformat methods #22418

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

Merged
merged 3 commits into from
Oct 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions Lib/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1421,7 +1421,8 @@ def isoformat(self, timespec='auto'):
part is omitted if self.microsecond == 0.

The optional argument timespec specifies the number of additional
terms of the time to include.
terms of the time to include. Valid options are 'auto', 'hours',
'minutes', 'seconds', 'milliseconds' and 'microseconds'.
"""
s = _format_time(self._hour, self._minute, self._second,
self._microsecond, timespec)
Expand Down Expand Up @@ -1906,7 +1907,8 @@ def isoformat(self, sep='T', timespec='auto'):
time, default 'T'.

The optional argument timespec specifies the number of additional
terms of the time to include.
terms of the time to include. Valid options are 'auto', 'hours',
'minutes', 'seconds', 'milliseconds' and 'microseconds'.
"""
s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day, sep) +
_format_time(self._hour, self._minute, self._second,
Expand Down
12 changes: 8 additions & 4 deletions Modules/_datetimemodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -4663,7 +4663,10 @@ static PyMethodDef time_methods[] = {
{"isoformat", (PyCFunction)(void(*)(void))time_isoformat, METH_VARARGS | METH_KEYWORDS,
PyDoc_STR("Return string in ISO 8601 format, [HH[:MM[:SS[.mmm[uuu]]]]]"
"[+HH:MM].\n\n"
"timespec specifies what components of the time to include.\n")},
"The optional argument timespec specifies the number "
"of additional terms\nof the time to include. Valid "
"options are 'auto', 'hours', 'minutes',\n'seconds', "
"'milliseconds' and 'microseconds'.\n")},

{"strftime", (PyCFunction)(void(*)(void))time_strftime, METH_VARARGS | METH_KEYWORDS,
PyDoc_STR("format -> strftime() style string.")},
Expand Down Expand Up @@ -6370,9 +6373,10 @@ static PyMethodDef datetime_methods[] = {
"YYYY-MM-DDT[HH[:MM[:SS[.mmm[uuu]]]]][+HH:MM].\n"
"sep is used to separate the year from the time, and "
"defaults to 'T'.\n"
"timespec specifies what components of the time to include"
" (allowed values are 'auto', 'hours', 'minutes', 'seconds',"
" 'milliseconds', and 'microseconds').\n")},
"The optional argument timespec specifies the number "
"of additional terms\nof the time to include. Valid "
"options are 'auto', 'hours', 'minutes',\n'seconds', "
"'milliseconds' and 'microseconds'.\n")},

{"utcoffset", (PyCFunction)datetime_utcoffset, METH_NOARGS,
PyDoc_STR("Return self.tzinfo.utcoffset(self).")},
Expand Down