diff --git a/CHANGELOG.rst b/CHANGELOG.rst index 1d27a579e..979833b9d 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -4,6 +4,9 @@ CHANGELOG 6.0.0b6 (unreleased) -------------------- +- Use pendulum's parser to deserialize datetime values (if it's installed). + Otherwise use current one. [masipcat] + - Undo datetime object renderization on guillotina_json_default. [lferran] diff --git a/guillotina/json/deserialize_value.py b/guillotina/json/deserialize_value.py index beecaae80..9d1e92db9 100644 --- a/guillotina/json/deserialize_value.py +++ b/guillotina/json/deserialize_value.py @@ -1,5 +1,16 @@ # -*- coding: utf-8 -*- -from dateutil.parser import parse + +try: + # Pendulum's parser is faster than dateutil.parser for dates with format + # RFC 3339/ISO 8601. See GH issue #974 for details. + from pendulum.parsing import parse as _parse + from functools import partial + + # When parse is called with `strict=False` it calls dateutil.parse() as fallback + parse = partial(_parse, strict=False) +except ImportError: + from dateutil.parser import parse + from guillotina import configure from guillotina.component import ComponentLookupError from guillotina.component import get_adapter