mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-01-24 16:24:15 +03:00
binary_reader: Parse TL 'date' to UTC datetime instead of local
This commit is contained in:
parent
7d4453351b
commit
f99d14558f
|
@ -113,7 +113,7 @@ class BinaryReader:
|
||||||
into a Python datetime object
|
into a Python datetime object
|
||||||
"""
|
"""
|
||||||
value = self.read_int()
|
value = self.read_int()
|
||||||
return None if value == 0 else datetime.fromtimestamp(value)
|
return None if value == 0 else datetime.utcfromtimestamp(value)
|
||||||
|
|
||||||
def tgread_object(self):
|
def tgread_object(self):
|
||||||
"""Reads a Telegram object"""
|
"""Reads a Telegram object"""
|
||||||
|
|
|
@ -36,7 +36,7 @@ class TLObject:
|
||||||
', '.join(TLObject.pretty_format(x) for x in obj)
|
', '.join(TLObject.pretty_format(x) for x in obj)
|
||||||
)
|
)
|
||||||
elif isinstance(obj, datetime):
|
elif isinstance(obj, datetime):
|
||||||
return 'datetime.fromtimestamp({})'.format(obj.timestamp())
|
return 'datetime.utcfromtimestamp({})'.format(obj.timestamp())
|
||||||
else:
|
else:
|
||||||
return repr(obj)
|
return repr(obj)
|
||||||
else:
|
else:
|
||||||
|
@ -81,7 +81,7 @@ class TLObject:
|
||||||
result.append(']')
|
result.append(']')
|
||||||
|
|
||||||
elif isinstance(obj, datetime):
|
elif isinstance(obj, datetime):
|
||||||
result.append('datetime.fromtimestamp(')
|
result.append('datetime.utcfromtimestamp(')
|
||||||
result.append(repr(obj.timestamp()))
|
result.append(repr(obj.timestamp()))
|
||||||
result.append(')')
|
result.append(')')
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user