3 ms·
There really should be a 'from_utc_timestamp(...)' which will cover 99% of timestamp parsing in Python. Because there's not means people are always dragging in
by declan_roberts 2y ago
There really should be a 'from_utc_timestamp(...)' which will cover 99% of timestamp parsing in Python.
Because there's not means people are always dragging in timezone libs or dealing with the consequences.
- klodolph 2y agoThere is .utcfromtimestamp(). The problem is that this function returns a naïve datetime. You don’t need to grab in a library, though. There is a UTC zone defined in the standard library. You pass it in as the second argument to .fromtinestamp(): datetime.fromtimestamp(ts, UTC)