INADA Naoki added the comment:

This is not a spelling issue.

When people writing code converting between unixtime and datetime,
they should find `.timestamp()` and `.utcfromtimestamp()`.
But they may not awake about `.replace(tzinfo=datetime.timezone.utc)` is very 
important.

Since `fromtimestamp` takes `tz` as optional 2nd argument,
I feel adding 2nd `aware` option to `utcfromtimestamp` is good for symmetry.


If 
`datetime.datetime.utcfromtimestamp(ts).replace(tzinfo=datetime.timezone.utc)`
is clearer than `datetime.datetime.utcfromtimestamp(ts, aware=True)`,
docstring of `utcfromtimestamp` should notice about how `replace()` important:

"""
Note that it returns **naive** (tz=None) datetime.  Since naive datetime is
treated as localtime in most functions, you may have to call 
`.replace(tzinfo=datetime.datetime.utc)` before using it.
"""

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue22791>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to