Merge pull request #948 from alligatorbait/master

String Check, catch NoneType error
This commit is contained in:
Garret Wassermann 2021-02-24 10:57:21 -05:00 committed by GitHub
commit 78a027b5a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -23,12 +23,13 @@ def datetime_string_format(value):
"""
try:
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_DATETIME_FORMAT), settings.DATETIME_FORMAT)
except ValueError:
except (TypeError, ValueError):
try:
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_DATE_FORMAT), settings.DATE_FORMAT)
except ValueError:
except (TypeError, ValueError):
try:
new_value = date_filter(datetime.strptime(value, CUSTOMFIELD_TIME_FORMAT), settings.TIME_FORMAT)
except ValueError:
new_value = value
except (TypeError, ValueError):
# If NoneType return empty string, else return original value
new_value = "" if value is None else value
return new_value