Handle exception on date format

merge-requests/30/head
Bob Mottram 2021-01-09 10:23:05 +00:00
parent c79ca40cc5
commit 7d22d2ec25
1 changed files with 6 additions and 2 deletions

View File

@ -47,8 +47,12 @@ def validPostDate(published: str, maxAgeDays=7) -> bool:
daysDiff = datetime.datetime.utcnow() - baselineTime
nowDaysSinceEpoch = daysDiff.days
postTimeObject = \
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
try:
postTimeObject = \
datetime.datetime.strptime(published, "%Y-%m-%dT%H:%M:%SZ")
except BaseException:
return False
daysDiff = postTimeObject - baselineTime
postDaysSinceEpoch = daysDiff.days