mirror of https://gitlab.com/bashrc2/epicyon
Handle exception on date format
parent
c79ca40cc5
commit
7d22d2ec25
8
utils.py
8
utils.py
|
@ -47,8 +47,12 @@ def validPostDate(published: str, maxAgeDays=7) -> bool:
|
||||||
daysDiff = datetime.datetime.utcnow() - baselineTime
|
daysDiff = datetime.datetime.utcnow() - baselineTime
|
||||||
nowDaysSinceEpoch = daysDiff.days
|
nowDaysSinceEpoch = daysDiff.days
|
||||||
|
|
||||||
postTimeObject = \
|
try:
|
||||||
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
postTimeObject = \
|
||||||
|
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
|
||||||
|
except BaseException:
|
||||||
|
return False
|
||||||
|
|
||||||
daysDiff = postTimeObject - baselineTime
|
daysDiff = postTimeObject - baselineTime
|
||||||
postDaysSinceEpoch = daysDiff.days
|
postDaysSinceEpoch = daysDiff.days
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue