From f99d14558fc964f37fa321f9f598e7fef83adba4 Mon Sep 17 00:00:00 2001 From: "Dmitry D. Chernov" Date: Thu, 23 Nov 2017 02:06:43 +1000 Subject: [PATCH] binary_reader: Parse TL 'date' to UTC datetime instead of local --- telethon/extensions/binary_reader.py | 2 +- telethon/tl/tlobject.py | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/telethon/extensions/binary_reader.py b/telethon/extensions/binary_reader.py index 2355c6a4..c5abcbf9 100644 --- a/telethon/extensions/binary_reader.py +++ b/telethon/extensions/binary_reader.py @@ -113,7 +113,7 @@ class BinaryReader: into a Python datetime object """ 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): """Reads a Telegram object""" diff --git a/telethon/tl/tlobject.py b/telethon/tl/tlobject.py index 1bd57878..2ba6ef14 100644 --- a/telethon/tl/tlobject.py +++ b/telethon/tl/tlobject.py @@ -36,7 +36,7 @@ class TLObject: ', '.join(TLObject.pretty_format(x) for x in obj) ) elif isinstance(obj, datetime): - return 'datetime.fromtimestamp({})'.format(obj.timestamp()) + return 'datetime.utcfromtimestamp({})'.format(obj.timestamp()) else: return repr(obj) else: @@ -81,7 +81,7 @@ class TLObject: result.append(']') elif isinstance(obj, datetime): - result.append('datetime.fromtimestamp(') + result.append('datetime.utcfromtimestamp(') result.append(repr(obj.timestamp())) result.append(')')