[issue22791] datetime.utcfromtimestamp() shoud have option for create tz aware datetime
Akira Li
report at bugs.python.org
Sun Nov 9 04:42:12 CET 2014
Akira Li added the comment:
>>> from datetime import datetime, timezone
>>> datetime.fromtimestamp(0, timezone.utc)
datetime.datetime(1970, 1, 1, 0, 0, tzinfo=datetime.timezone.utc)
already works and it is documented [1]
[1] https://docs.python.org/3/library/datetime.html#datetime.datetime.fromtimestamp
Or it can be written as:
>>> epoch = datetime(1970, 1, 1, tzinfo=timezone.utc)
>>> aware_utc = epoch + timedelta(seconds=posix_timestamp)
----------
nosy: +akira
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22791>
_______________________________________
More information about the Python-bugs-list
mailing list