Skip to content

Commit 8ca0831

Browse files
[3.9] bpo-41867: List options for timespec in docstrings of isoformat methods (GH-22418)
(cherry picked from commit 5230131) Co-authored-by: Ram Rachum <ram@rachum.com>
1 parent ef7b937 commit 8ca0831

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Lib/datetime.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1452,7 +1452,8 @@ def isoformat(self, timespec='auto'):
14521452
part is omitted if self.microsecond == 0.
14531453
14541454
The optional argument timespec specifies the number of additional
1455-
terms of the time to include.
1455+
terms of the time to include. Valid options are 'auto', 'hours',
1456+
'minutes', 'seconds', 'milliseconds' and 'microseconds'.
14561457
"""
14571458
s = _format_time(self._hour, self._minute, self._second,
14581459
self._microsecond, timespec)
@@ -1937,7 +1938,8 @@ def isoformat(self, sep='T', timespec='auto'):
19371938
time, default 'T'.
19381939
19391940
The optional argument timespec specifies the number of additional
1940-
terms of the time to include.
1941+
terms of the time to include. Valid options are 'auto', 'hours',
1942+
'minutes', 'seconds', 'milliseconds' and 'microseconds'.
19411943
"""
19421944
s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day, sep) +
19431945
_format_time(self._hour, self._minute, self._second,

Modules/_datetimemodule.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4673,7 +4673,10 @@ static PyMethodDef time_methods[] = {
46734673
{"isoformat", (PyCFunction)(void(*)(void))time_isoformat, METH_VARARGS | METH_KEYWORDS,
46744674
PyDoc_STR("Return string in ISO 8601 format, [HH[:MM[:SS[.mmm[uuu]]]]]"
46754675
"[+HH:MM].\n\n"
4676-
"timespec specifies what components of the time to include.\n")},
4676+
"The optional argument timespec specifies the number "
4677+
"of additional terms\nof the time to include. Valid "
4678+
"options are 'auto', 'hours', 'minutes',\n'seconds', "
4679+
"'milliseconds' and 'microseconds'.\n")},
46774680

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

63876391
{"utcoffset", (PyCFunction)datetime_utcoffset, METH_NOARGS,
63886392
PyDoc_STR("Return self.tzinfo.utcoffset(self).")},

0 commit comments

Comments
 (0)