mirror of
https://github.com/aiogram/aiogram.git
synced 2025-12-12 18:19:34 +00:00
Allow to use datetime and timedelta in until_date argument.
This commit is contained in:
parent
5d81515487
commit
bd91d0acb9
2 changed files with 19 additions and 7 deletions
|
|
@ -1,3 +1,5 @@
|
|||
import datetime
|
||||
|
||||
from . import json
|
||||
|
||||
DEFAULT_FILTER = ['self']
|
||||
|
|
@ -17,4 +19,9 @@ def prepare_arg(value):
|
|||
return json.dumps(value)
|
||||
elif hasattr(value, 'to_json'):
|
||||
return json.dumps(value.to_json())
|
||||
elif isinstance(value, datetime.timedelta):
|
||||
now = datetime.datetime.now()
|
||||
return int((now + value).timestamp())
|
||||
elif isinstance(value, datetime.datetime):
|
||||
return int(value.timestamp())
|
||||
return value
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue