Allow to use datetime and timedelta in until_date argument.

This commit is contained in:
Alex Root Junior 2017-08-04 13:12:33 +03:00
parent 5d81515487
commit bd91d0acb9
2 changed files with 19 additions and 7 deletions

View file

@ -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