mirror of
https://github.com/pkkid/python-plexapi
synced 2025-02-16 21:08:27 +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 value and value is not None:
|
||||||
if format:
|
if format:
|
||||||
value = datetime.strptime(value, format)
|
try:
|
||||||
|
value = datetime.strptime(value, format)
|
||||||
|
except ValueError:
|
||||||
|
# parsing failed
|
||||||
|
return None
|
||||||
else:
|
else:
|
||||||
# https://bugs.python.org/issue30684
|
# https://bugs.python.org/issue30684
|
||||||
# And platform support for before epoch seems to be flaky.
|
# And platform support for before epoch seems to be flaky.
|
||||||
|
|
Loading…
Add table
Reference in a new issue