python: use datetime.fromtimestamp() instead of datetime.utcfromtimestamp()

utcfromtimestamp() is not recommended by the official documentation,
because many methods, including timestamp(), work incorrectly with
"naive" datetimes returned by utcfromtimestamp().
This commit is contained in:
link2xt
2021-10-30 22:15:01 +00:00
parent 54e79409e6
commit 3e60ee9d3e
4 changed files with 13 additions and 12 deletions

View File

@@ -1,6 +1,6 @@
from .capi import lib
from .capi import ffi
from datetime import datetime
from datetime import datetime, timezone
def as_dc_charpointer(obj):
@@ -44,4 +44,4 @@ class DCLot:
ts = lib.dc_lot_get_timestamp(self._dc_lot)
if ts == 0:
return None
return datetime.utcfromtimestamp(ts)
return datetime.fromtimestamp(ts, timezone.utc)