Account for LBTC time formats
This commit is contained in:
parent
ddee10958f
commit
9b3f36cc44
|
@ -1,6 +1,6 @@
|
||||||
# Other library imports
|
# Other library imports
|
||||||
from httpx import ReadTimeout, ReadError, RemoteProtocolError
|
from httpx import ReadTimeout, ReadError, RemoteProtocolError
|
||||||
from datetime import datetime
|
from datetime import datetime, timezone
|
||||||
import logging
|
import logging
|
||||||
|
|
||||||
# Project imports
|
# Project imports
|
||||||
|
@ -115,8 +115,18 @@ def last_online_recent(date):
|
||||||
:return: bool indicating whether the date was recent enough
|
:return: bool indicating whether the date was recent enough
|
||||||
:rtype: bool
|
:rtype: bool
|
||||||
"""
|
"""
|
||||||
date_parsed = datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ")
|
if "+" in date:
|
||||||
now = datetime.now()
|
# for LBTC
|
||||||
|
# 2022-04-16T08:53:58+00:00
|
||||||
|
date_split = date.split("+")
|
||||||
|
date[1].replace(".", "")
|
||||||
|
date[1].replace(":", "")
|
||||||
|
date = "+".join(date_split)
|
||||||
|
date_string = "%Y-%m-%dT%H:%M:%S%z"
|
||||||
|
else:
|
||||||
|
date_string = "%Y-%m-%dT%H:%M:%S.%fZ"
|
||||||
|
date_parsed = datetime.strptime(date, date_string)
|
||||||
|
now = datetime.now(timezone.utc)
|
||||||
sec_ago_date = (now - date_parsed).total_seconds()
|
sec_ago_date = (now - date_parsed).total_seconds()
|
||||||
return sec_ago_date < 172800
|
return sec_ago_date < 172800
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue