customize dateparser to use YMD order
This commit is contained in:
parent
87627cef46
commit
d84be4ee41
1 changed files with 4 additions and 4 deletions
|
@ -84,15 +84,15 @@ def parse_datetime_float(date_str: str) -> float:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import dateparser # type: ignore[import]
|
import dateparser # type: ignore[import]
|
||||||
|
except ImportError:
|
||||||
|
pass
|
||||||
|
else:
|
||||||
# dateparser is a bit more lenient than the above, lets you type
|
# dateparser is a bit more lenient than the above, lets you type
|
||||||
# all sorts of dates as inputs
|
# all sorts of dates as inputs
|
||||||
# https://github.com/scrapinghub/dateparser#how-to-use
|
# https://github.com/scrapinghub/dateparser#how-to-use
|
||||||
|
res: Optional[datetime] = dateparser.parse(ds, settings={"DATE_ORDER": "YMD"})
|
||||||
res: Optional[datetime] = dateparser.parse(ds)
|
|
||||||
if res is not None:
|
if res is not None:
|
||||||
return res.timestamp()
|
return res.timestamp()
|
||||||
except ImportError:
|
|
||||||
pass
|
|
||||||
|
|
||||||
raise QueryException(f"Was not able to parse {ds} into a datetime")
|
raise QueryException(f"Was not able to parse {ds} into a datetime")
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue