Skip to content

Commit 99cc3d1

Browse files
[3.13] gh-57095: Add note about input splitting in datetime.*.strptime (GH-131049) (GH-144734)
(cherry picked from commit 2e3e76e) Co-authored-by: Petr Viktorin <encukou@gmail.com>
1 parent 009583f commit 99cc3d1

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Doc/library/datetime.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2591,6 +2591,12 @@ For the :meth:`.datetime.strptime` class method, the default value is
25912591
``1900-01-01T00:00:00.000``: any components not specified in the format string
25922592
will be pulled from the default value.
25932593

2594+
.. note::
2595+
Format strings without separators can be ambiguous for parsing. For
2596+
example, with ``%Y%m%d``, the string ``2026111`` may be parsed either as
2597+
``2026-11-01`` or as ``2026-01-11``.
2598+
Use separators to ensure the input is parsed as intended.
2599+
25942600
.. note::
25952601
When used to parse partial dates lacking a year, :meth:`.datetime.strptime`
25962602
will raise when encountering February 29 because the default year of 1900 is

0 commit comments

Comments
 (0)