Skip to content

Commit a02bc71

Browse files
bpo-27741: Better wording for datetime.strptime() (GH-9994)
(cherry picked from commit c0799ec) Co-authored-by: Gus Goulart <augusto@goulart.me>
1 parent f00703d commit a02bc71

1 file changed

Lines changed: 3 additions & 1 deletion

File tree

Doc/library/datetime.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2016,7 +2016,9 @@ although not all objects support a :meth:`timetuple` method.
20162016
Conversely, the :meth:`datetime.strptime` class method creates a
20172017
:class:`.datetime` object from a string representing a date and time and a
20182018
corresponding format string. ``datetime.strptime(date_string, format)`` is
2019-
equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``.
2019+
equivalent to ``datetime(*(time.strptime(date_string, format)[0:6]))``, except
2020+
when the format includes sub-second components or timezone offset information,
2021+
which are supported in ``datetime.strptime`` but are discarded by ``time.strptime``.
20202022

20212023
For :class:`.time` objects, the format codes for year, month, and day should not
20222024
be used, as time objects have no such values. If they're used anyway, ``1900``

0 commit comments

Comments
 (0)