Message230636
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.
""" |
|
Date |
User |
Action |
Args |
2014-11-04 16:37:54 | methane | set | recipients:
+ methane, belopolsky, r.david.murray |
2014-11-04 16:37:54 | methane | set | messageid: <1415119074.51.0.228889047772.issue22791@psf.upfronthosting.co.za> |
2014-11-04 16:37:54 | methane | link | issue22791 messages |
2014-11-04 16:37:54 | methane | create | |
|