mirror of
https://github.com/pkkid/python-plexapi
synced 2024-11-22 11:43:13 +00:00
Do not fail while parsing illegal dates. Return None instead.
This commit is contained in:
parent
bd033a9f7e
commit
25c619032f
1 changed files with 5 additions and 1 deletions
|
@ -176,7 +176,11 @@ def toDatetime(value, format=None):
|
|||
"""
|
||||
if value and value is not None:
|
||||
if format:
|
||||
value = datetime.strptime(value, format)
|
||||
try:
|
||||
value = datetime.strptime(value, format)
|
||||
except ValueError:
|
||||
# parsing failed
|
||||
return None
|
||||
else:
|
||||
# https://bugs.python.org/issue30684
|
||||
# And platform support for before epoch seems to be flaky.
|
||||
|
|
Loading…
Reference in a new issue