From dc3d28127431d1c03e3c15ade96054ad7a3aba74 Mon Sep 17 00:00:00 2001 From: Lonami Exo Date: Sat, 14 Jul 2018 00:01:45 +0200 Subject: [PATCH] Load update state date with explicit timezone (#808) --- telethon/sessions/sqlite.py | 3 ++- telethon/tl/tlobject.py | 5 ----- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/telethon/sessions/sqlite.py b/telethon/sessions/sqlite.py index 4f6967aa..7d81f00c 100644 --- a/telethon/sessions/sqlite.py +++ b/telethon/sessions/sqlite.py @@ -211,7 +211,8 @@ class SQLiteSession(MemorySession): 'where id = ?', entity_id) if row: pts, qts, date, seq = row - date = datetime.datetime.utcfromtimestamp(date) + date = datetime.datetime.fromtimestamp( + date, tz=datetime.timezone.utc) return types.updates.State(pts, qts, date, seq, unread_count=0) def set_update_state(self, entity_id, state): diff --git a/telethon/tl/tlobject.py b/telethon/tl/tlobject.py index 52b86b71..cc0d9ab3 100644 --- a/telethon/tl/tlobject.py +++ b/telethon/tl/tlobject.py @@ -65,11 +65,6 @@ class TLObject: result.append('\t' * indent) result.append(']') - elif isinstance(obj, datetime): - result.append('datetime.utcfromtimestamp(') - result.append(repr(int(obj.timestamp()))) - result.append(')') - else: result.append(repr(obj))