@@ -719,13 +719,25 @@ Instance methods:
719719 .. versionchanged :: 3.9
720720 Result changed from a tuple to a :term: `named tuple `.
721721
722- .. method :: date.isoformat()
723722
724- Return a string representing the date in ISO 8601 format, ``YYYY-MM-DD ``::
723+ .. method :: date.isoformat(basic=False)
724+
725+ Return a string representing the date in:
726+
727+ - ISO 8601 extended format ``YYYY-MM-DD `` (the default), or
728+ - ISO 8601 basic format ``YYYYMMDD `` via the *basic * argument.
729+
730+ Examples:
725731
726732 >>> from datetime import date
727733 >>> date(2002 , 12 , 4 ).isoformat()
728734 '2002-12-04'
735+ >>> date(2002 , 12 , 4 ).isoformat(basic = True )
736+ '20021204'
737+
738+ .. versionchanged :: 3.14
739+ Added the *basic * parameter.
740+
729741
730742.. method :: date.__str__()
731743
@@ -1479,9 +1491,9 @@ Instance methods:
14791491 and ``weekday ``. The same as ``self.date().isocalendar() ``.
14801492
14811493
1482- .. method :: datetime.isoformat(sep='T', timespec='auto')
1494+ .. method :: datetime.isoformat(sep='T', timespec='auto', basic=False )
14831495
1484- Return a string representing the date and time in ISO 8601 format:
1496+ Return a string representing the date and time in ISO 8601 extended format:
14851497
14861498 - ``YYYY-MM-DDTHH:MM:SS.ffffff ``, if :attr: `microsecond ` is not 0
14871499 - ``YYYY-MM-DDTHH:MM:SS ``, if :attr: `microsecond ` is 0
@@ -1493,13 +1505,20 @@ Instance methods:
14931505 is not 0
14941506 - ``YYYY-MM-DDTHH:MM:SS+HH:MM[:SS[.ffffff]] ``, if :attr: `microsecond ` is 0
14951507
1508+ If *basic * is true, this uses the ISO 8601 basic format for the date,
1509+ time and offset components.
1510+
14961511 Examples::
14971512
14981513 >>> from datetime import datetime, timezone
14991514 >>> datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat()
15001515 '2019-05-18T15:17:08.132263'
1516+ >>> datetime(2019, 5, 18, 15, 17, 8, 132263).isoformat(basic=True)
1517+ '20190518T151708.132263'
15011518 >>> datetime(2019, 5, 18, 15, 17, tzinfo=timezone.utc).isoformat()
15021519 '2019-05-18T15:17:00+00:00'
1520+ >>> datetime(2019, 5, 18, 15, 17, tzinfo=timezone.utc).isoformat(basic=True)
1521+ '20190518T151700+0000'
15031522
15041523 The optional argument *sep * (default ``'T' ``) is a one-character separator,
15051524 placed between the date and time portions of the result. For example::
@@ -1546,6 +1565,9 @@ Instance methods:
15461565 .. versionchanged :: 3.6
15471566 Added the *timespec * parameter.
15481567
1568+ .. versionadded :: 3.14
1569+ Added the *basic * parameter.
1570+
15491571
15501572.. method :: datetime.__str__()
15511573
@@ -1881,15 +1903,22 @@ Instance methods:
18811903 Added the *fold * parameter.
18821904
18831905
1884- .. method :: time.isoformat(timespec='auto')
1906+ .. method :: time.isoformat(timespec='auto', basic=False )
18851907
1886- Return a string representing the time in ISO 8601 format, one of:
1908+ Return a string representing the time in ISO 8601 (extended) format, one of:
18871909
18881910 - ``HH:MM:SS.ffffff ``, if :attr: `microsecond ` is not 0
18891911 - ``HH:MM:SS ``, if :attr: `microsecond ` is 0
18901912 - ``HH:MM:SS.ffffff+HH:MM[:SS[.ffffff]] ``, if :meth: `utcoffset ` does not return ``None ``
18911913 - ``HH:MM:SS+HH:MM[:SS[.ffffff]] ``, if :attr: `microsecond ` is 0 and :meth: `utcoffset ` does not return ``None ``
18921914
1915+ If *basic * is true, this uses the ISO 8601 basic format, one of:
1916+
1917+ - ``HHMMSS ``
1918+ - ``HHMMSS.ffffff ``
1919+ - ``HHMMSS+HHMM[SS[.ffffff]] ``
1920+ - ``HHMMSS.ffffff+HHMM[SS[.ffffff]] ``
1921+
18931922 The optional argument *timespec * specifies the number of additional
18941923 components of the time to include (the default is ``'auto' ``).
18951924 It can be one of the following:
@@ -1924,6 +1953,9 @@ Instance methods:
19241953 .. versionchanged :: 3.6
19251954 Added the *timespec * parameter.
19261955
1956+ .. versionchanged :: 3.14
1957+ Added the *basic * parameter.
1958+
19271959
19281960.. method :: time.__str__()
19291961
0 commit comments