Skip to content

Commit 7f5a3ac

Browse files
[3.14] gh-57095: Add note about input splitting in datetime.*.strptime (GH-131049) (GH-144735)
(cherry picked from commit 2e3e76e) Co-authored-by: Stan Ulbrych <89152624+StanFromIreland@users.noreply.github.com>
1 parent 4d3e8c1 commit 7f5a3ac

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
@@ -2638,6 +2638,12 @@ For the :meth:`.datetime.strptime` and :meth:`.date.strptime` class methods,
26382638
the default value is ``1900-01-01T00:00:00.000``: any components not specified
26392639
in the format string will be pulled from the default value.
26402640

2641+
.. note::
2642+
Format strings without separators can be ambiguous for parsing. For
2643+
example, with ``%Y%m%d``, the string ``2026111`` may be parsed either as
2644+
``2026-11-01`` or as ``2026-01-11``.
2645+
Use separators to ensure the input is parsed as intended.
2646+
26412647
.. note::
26422648
When used to parse partial dates lacking a year, :meth:`.datetime.strptime`
26432649
and :meth:`.date.strptime` will raise when encountering February 29 because

0 commit comments

Comments
 (0)