mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-25 00:34:19 +03:00
Set timezone info when reading datetimes
This commit is contained in:
parent
8b4c8d30e7
commit
38c65adf35
|
@ -2,7 +2,7 @@
|
|||
This module contains the BinaryReader utility class.
|
||||
"""
|
||||
import os
|
||||
from datetime import datetime
|
||||
from datetime import datetime, timezone
|
||||
from io import BufferedReader, BytesIO
|
||||
from struct import unpack
|
||||
|
||||
|
@ -120,7 +120,10 @@ class BinaryReader:
|
|||
into a Python datetime object.
|
||||
"""
|
||||
value = self.read_int()
|
||||
return None if value == 0 else datetime.utcfromtimestamp(value)
|
||||
if value == 0:
|
||||
return None
|
||||
else:
|
||||
return datetime.fromtimestamp(value, tz=timezone.utc)
|
||||
|
||||
def tgread_object(self):
|
||||
"""Reads a Telegram object."""
|
||||
|
|
|
@ -24,10 +24,6 @@ class TLObject:
|
|||
return '[{}]'.format(
|
||||
', '.join(TLObject.pretty_format(x) for x in obj)
|
||||
)
|
||||
elif isinstance(obj, datetime):
|
||||
return 'datetime.utcfromtimestamp({})'.format(
|
||||
int(obj.timestamp())
|
||||
)
|
||||
else:
|
||||
return repr(obj)
|
||||
else:
|
||||
|
|
Loading…
Reference in New Issue
Block a user