This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author taleinat
Recipients Valectar, augustogoulart, belopolsky, docs@python, fhackdroid, p-ganssle, taleinat, xtreak
Date 2018-10-12.08:52:17
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1539334337.59.0.788709270274.issue27741@psf.upfronthosting.co.za>
In-reply-to
Content
At least with Python 3.7.0, the equivalence is not complete: datetime.strptime() is better, since it retains both microseconds and timezone data. See examples below.

>>> from datetime import datetime, timezone
>>> import time
>>> s = datetime.strftime(datetime.now(), '%a %b %d %H:%M:%S %f')
>>> s
'Fri Oct 12 11:33:32 999810'
>>> datetime.strptime(s, '%a %b %d %H:%M:%S %f')
datetime.datetime(1900, 10, 12, 11, 33, 32, 999810)
>>> datetime(*time.strptime(s, '%a %b %d %H:%M:%S %f')[:6])
datetime.datetime(1900, 10, 12, 11, 33, 32)
>>> s2 = datetime.strftime(datetime.now(timezone(timedelta(hours=1))), '%a %b %d %H:%M:%S %f%z')
>>> s2
'Fri Oct 12 09:48:40 347076+0100'
>>> datetime.strptime(s2, '%a %b %d %H:%M:%S %f%z')
datetime.datetime(1900, 10, 12, 9, 48, 40, 347076, tzinfo=datetime.timezone(datetime.timedelta(seconds=3600)))
>>> datetime(*time.strptime(s2, '%a %b %d %H:%M:%S %f%z')[:6])
datetime.datetime(1900, 10, 12, 9, 48, 40)
History
Date User Action Args
2018-10-12 08:52:17taleinatsetrecipients: + taleinat, belopolsky, docs@python, Valectar, p-ganssle, fhackdroid, augustogoulart, xtreak
2018-10-12 08:52:17taleinatsetmessageid: <1539334337.59.0.788709270274.issue27741@psf.upfronthosting.co.za>
2018-10-12 08:52:17taleinatlinkissue27741 messages
2018-10-12 08:52:17taleinatcreate