binary_reader: Parse TL 'date' to UTC datetime instead of local

This commit is contained in:
Dmitry D. Chernov 2017-11-23 02:06:43 +10:00
parent 7d4453351b
commit f99d14558f
2 changed files with 3 additions and 3 deletions

View File

@ -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"""

View File

@ -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(')')