mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-04-21 17:42:01 +03:00
Fix serialize_datetime (edits)
Add checks to prevent `struct.pack()` from failing and for users to not use dates outside the ranges of 1970 to 2038.
This commit is contained in:
parent
be6bb94e00
commit
730a8ed380
|
@ -135,7 +135,11 @@ class TLObject:
|
|||
dt = int(dt.total_seconds())
|
||||
except OSError:
|
||||
dt = 0
|
||||
|
||||
|
||||
# 2145916800 is the date 2038, 1, 1.
|
||||
if dt > 2145916800:
|
||||
raise ValueError("Date is outside the range of valid values.")
|
||||
|
||||
if isinstance(dt, int):
|
||||
return struct.pack('<i', dt)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user