Skip to content

Commit 25c6190

Browse files
author
Simone Pierazzini
committed
Do not fail while parsing illegal dates. Return None instead.
1 parent bd033a9 commit 25c6190

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

plexapi/utils.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,11 @@ def toDatetime(value, format=None):
176176
"""
177177
if value and value is not None:
178178
if format:
179-
value = datetime.strptime(value, format)
179+
try:
180+
value = datetime.strptime(value, format)
181+
except ValueError:
182+
# parsing failed
183+
return None
180184
else:
181185
# https://bugs.python.org/issue30684
182186
# And platform support for before epoch seems to be flaky.

0 commit comments

Comments
 (0)