summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--lesana/types.py4
1 files changed, 3 insertions, 1 deletions
diff --git a/lesana/types.py b/lesana/types.py
index ce15b69..1d5322e 100644
--- a/lesana/types.py
+++ b/lesana/types.py
@@ -202,9 +202,11 @@ class LesanaDatetime(LesanaType):
return data
if isinstance(data, datetime.date):
return datetime.datetime(data.year, data.month, data.day)
+ # compatibility with dateutil before 2.8
+ ParserError = getattr(dateutil.parser, 'ParserError', ValueError)
try:
return dateutil.parser.parse(data)
- except dateutil.parser.ParserError:
+ except ParserError:
raise LesanaValueError(
"Invalid value for datetime field: {}".format(data)
)