Skip to content

Commit 5230131

Browse files
authored
bpo-41867: List options for timespec in docstrings of isoformat methods (pythonGH-22418)
1 parent f97e42e commit 5230131

File tree

2 files changed

+12
-6
lines changed

2 files changed

+12
-6
lines changed

Lib/datetime.py

+4-2
Original file line numberDiff line numberDiff line change
@@ -1421,7 +1421,8 @@ def isoformat(self, timespec='auto'):
14211421
part is omitted if self.microsecond == 0.
14221422
14231423
The optional argument timespec specifies the number of additional
1424-
terms of the time to include.
1424+
terms of the time to include. Valid options are 'auto', 'hours',
1425+
'minutes', 'seconds', 'milliseconds' and 'microseconds'.
14251426
"""
14261427
s = _format_time(self._hour, self._minute, self._second,
14271428
self._microsecond, timespec)
@@ -1906,7 +1907,8 @@ def isoformat(self, sep='T', timespec='auto'):
19061907
time, default 'T'.
19071908
19081909
The optional argument timespec specifies the number of additional
1909-
terms of the time to include.
1910+
terms of the time to include. Valid options are 'auto', 'hours',
1911+
'minutes', 'seconds', 'milliseconds' and 'microseconds'.
19101912
"""
19111913
s = ("%04d-%02d-%02d%c" % (self._year, self._month, self._day, sep) +
19121914
_format_time(self._hour, self._minute, self._second,

Modules/_datetimemodule.c

+8-4
Original file line numberDiff line numberDiff line change
@@ -4663,7 +4663,10 @@ static PyMethodDef time_methods[] = {
46634663
{"isoformat", (PyCFunction)(void(*)(void))time_isoformat, METH_VARARGS | METH_KEYWORDS,
46644664
PyDoc_STR("Return string in ISO 8601 format, [HH[:MM[:SS[.mmm[uuu]]]]]"
46654665
"[+HH:MM].\n\n"
4666-
"timespec specifies what components of the time to include.\n")},
4666+
"The optional argument timespec specifies the number "
4667+
"of additional terms\nof the time to include. Valid "
4668+
"options are 'auto', 'hours', 'minutes',\n'seconds', "
4669+
"'milliseconds' and 'microseconds'.\n")},
46674670

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

63776381
{"utcoffset", (PyCFunction)datetime_utcoffset, METH_NOARGS,
63786382
PyDoc_STR("Return self.tzinfo.utcoffset(self).")},

0 commit comments

Comments
 (0)