mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-07-11 16:42:28 +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
|
@ -136,6 +136,10 @@ class TLObject:
|
||||||
except OSError:
|
except OSError:
|
||||||
dt = 0
|
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):
|
if isinstance(dt, int):
|
||||||
return struct.pack('<i', dt)
|
return struct.pack('<i', dt)
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user