Skip to content

Commit a1f91de

Browse files
Update Doc/library/datetime.rst
Co-authored-by: Stan Ulbrych <stan@python.org>
1 parent f8937f1 commit a1f91de

1 file changed

Lines changed: 5 additions & 6 deletions

File tree

‎Doc/library/datetime.rst‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2746,12 +2746,11 @@ in the format string will be pulled from the default value.
27462746
year to partial date strings before parsing.
27472747

27482748
.. note::
2749-
When parsing a string using :meth:`.datetime.strptime` or
2750-
:meth:`.date.strptime`, if more than one directive for the same time unit
2751-
is used, only the last directive is parsed and applied to the resulting
2752-
object. For example, if the format string contains both ``%Y`` and ``%y``,
2753-
like ``%Y%y``, only the last directive in the string (``%y``) determines
2754-
the year of the result.
2749+
If a :meth:`~.datetime.strptime` format string contains more than
2750+
one directive for the same field, for example both ``%Y`` and ``%y``,
2751+
every directive must still match the input, but only the value of the
2752+
last one is used. For example, parsing ``200099`` with ``%Y%y`` gives
2753+
the year 1999. Repeating the same directive, like ``%Y%Y``, raises an error.
27552754

27562755
.. testsetup::
27572756

0 commit comments

Comments
 (0)