Closed thedrow closed 5 years ago
I strongly disagree with this for a number of reasons, the foremost of which is that you should not be using utcfromtimestamp
even in Python.
For one thing, it's not part of the C API - we have bindings for everything that's in the C API, and utcfromtimestamp
is not part of that.
For another, the utcfromtimestamp
and utcnow
are both problematic in that they represent a specific time in a specific time zone using a naive datetime
object, but many methods on datetime
treat a naive datetime as being in your local time. Those methods are essentially broken because they are inconsistent with either model for datetime
- the one where a bare datetime
refers to an abstract datetime and the one where a bare datetime
refers to the datetime
in local time. If you want a datetime
from a timestamp in UTC, you should use datetime.fromtimestamp(ts, datetime.timezone.utc)
.
I believe we have the FFI bindings for the datetime.timezone.utc
singleton in Python 3.7+, but we still need safe Rust wrappers for it.
utcfromtimestamp is a very common method. I believe it should be part of the API.