Thanks to visit codestin.com
Credit goes to github.com

Skip to content

GH-124549: Add a note that when over-specifying datetime format, only the last directive gets used. #125009

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions Doc/library/datetime.rst
Original file line number Diff line number Diff line change
Expand Up @@ -2761,6 +2761,14 @@ Notes:
:exc:`DeprecationWarning`. In 3.15 or later we may change this into
an error or change the default year to a leap year. See :gh:`70647`.

(11)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is a note here the best place for this?

When parsing a string using :meth:`~.datetime.strptime`, if more than one
directives of the same time unit were used, only the last directive gets parsed
and applied to the datetime object. For example, if the format string contains
both ``%Y`` and ``%y``, like ``%Y%y``, only the last directive on the string (``%y``)
gets used on the resulting datetime object.


.. rubric:: Footnotes

.. [#] If, that is, we ignore the effects of Relativity
Expand Down
Loading