Catch error for dateutil

In the event the server has some weird date that can't be converted
This commit is contained in:
angelblue05 2019-01-10 20:36:20 -06:00
parent 67377922a4
commit 1942f05559

View file

@ -450,11 +450,16 @@ def convert_to_local(date):
''' Convert the local datetime to local.
'''
try:
date = convert_str_to_date(date) if type(date) in (unicode, str) else date
date = date.replace(tzinfo=tz.tzutc())
date = date.astimezone(tz.tzlocal())
return date.strftime('%Y-%m-%dT%H:%M:%S')
except Exception as error:
LOG.error(error)
return str(date)
def convert_str_to_date(date):