Skip to content

Commit 4988071

Browse files
committed
Add a note that when over-specifying datetime format, only the last directive gets used.
1 parent 16cd6cc commit 4988071

1 file changed

Lines changed: 8 additions & 0 deletions

File tree

‎Doc/library/datetime.rst‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2761,6 +2761,14 @@ Notes:
27612761
:exc:`DeprecationWarning`. In 3.15 or later we may change this into
27622762
an error or change the default year to a leap year. See :gh:`70647`.
27632763

2764+
(11)
2765+
When parsing a string using :meth:`~.datetime.strptime`, if more than one
2766+
directives of the same time unit were used, only the last directive gets parsed
2767+
and applied to the datetime object. For example, if the format string contains
2768+
both ``%Y`` and ``%y``, like ``%Y%y``, only the last directive on the string (``%y``)
2769+
gets used on the resulting datetime object.
2770+
2771+
27642772
.. rubric:: Footnotes
27652773

27662774
.. [#] If, that is, we ignore the effects of Relativity

0 commit comments

Comments
 (0)