mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-13 04:56:35 +03:00
Support timedelta as datetimes
This commit is contained in:
parent
1437b69829
commit
4328663c78
|
@ -1,5 +1,5 @@
|
||||||
import struct
|
import struct
|
||||||
from datetime import datetime, date
|
from datetime import datetime, date, timedelta
|
||||||
|
|
||||||
|
|
||||||
class TLObject:
|
class TLObject:
|
||||||
|
@ -125,6 +125,9 @@ class TLObject:
|
||||||
dt = int(datetime(dt.year, dt.month, dt.day).timestamp())
|
dt = int(datetime(dt.year, dt.month, dt.day).timestamp())
|
||||||
elif isinstance(dt, float):
|
elif isinstance(dt, float):
|
||||||
dt = int(dt)
|
dt = int(dt)
|
||||||
|
elif isinstance(dt, timedelta):
|
||||||
|
# Timezones are tricky. datetime.now() + ... timestamp() works
|
||||||
|
dt = int((datetime.now() + dt).timestamp())
|
||||||
|
|
||||||
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