-
-
Notifications
You must be signed in to change notification settings - Fork 32.4k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Documentation
The documentation for datetime.datetime.strptime is incorrect:
cpython/Doc/library/datetime.rst
Lines 1048 to 1050 in bb8b931
This is equivalent to:: | |
datetime(*(time.strptime(date_string, format)[0:6])) |
This is incorrect if format
contains microseconds or timezone information. Counterexample:
>>> timestr = '20200304050607.554321'
>>> print(datetime.strptime(timestr, '%Y%m%d%H%M%S.%f'))
2020-03-04 05:06:07.554321
>>> print(datetime(*(time.strptime(timestr, '%Y%m%d%H%M%S.%f')[0:6])))
2020-03-04 05:06:07
I suggest removing the cited part entirely, since since I see no easy way of correcting these lines, especially concerning timezones.
Linked PRs
tomaarsen and r-mohammadi
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir