From f6d46e38706cc0c277af0f0e01e076266bed1390 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Sun, 16 Jun 2019 12:34:10 +0200 Subject: [PATCH] Fix date/datetime helpers assertion errors --- LdapServer.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/LdapServer.py b/LdapServer.py index 4ff5396..39bc043 100644 --- a/LdapServer.py +++ b/LdapServer.py @@ -154,8 +154,8 @@ class LdapServerException(BaseException): # Helpers # def parse_datetime(value, to_timezone=None, default_timezone=None): - assert to_timezone is None or isinstance(to_timezone, datetime.tzinfo), 'to_timezone must be None or datetime.tzinfo object (not %s)' % type(value) - assert default_timezone is None or isinstance(default_timezone, datetime.tzinfo) or isinstance(default_timezone, pytz.tzinfo.DstTzInfo) or isinstance(default_timezone, str), 'default_timezone parameter must be None, a string, a pytz.tzinfo.DstTzInfo or a datetime.tzinfo object (not %s)' % type(from_timezone) + assert to_timezone is None or isinstance(to_timezone, datetime.tzinfo), 'to_timezone must be None or datetime.tzinfo object (not %s)' % type(to_timezone) + assert default_timezone is None or isinstance(default_timezone, datetime.tzinfo) or isinstance(default_timezone, pytz.tzinfo.DstTzInfo) or isinstance(default_timezone, str), 'default_timezone parameter must be None, a string, a pytz.tzinfo.DstTzInfo or a datetime.tzinfo object (not %s)' % type(default_timezone) date = dateutil.parser.parse(value, dayfirst=False) if not date.tzinfo: if not default_timezone: @@ -178,7 +178,7 @@ def parse_date(value, to_timezone=None, default_timezone=None): def format_datetime(value, from_timezone=None, to_timezone=None): assert isinstance(value, datetime.datetime), 'First parameter must be an datetime.datetime object (not %s)' % type(value) assert from_timezone is None or isinstance(from_timezone, datetime.tzinfo) or isinstance(from_timezone, pytz.tzinfo.DstTzInfo) or isinstance(from_timezone, str), 'from_timezone parameter must be None, a string, a pytz.tzinfo.DstTzInfo or a datetime.tzinfo object (not %s)' % type(from_timezone) - assert to_timezone is None or isinstance(to_timezone, datetime.tzinfo), 'to_timezone must be None or datetime.tzinfo object (not %s)' % type(value) + assert to_timezone is None or isinstance(to_timezone, datetime.tzinfo), 'to_timezone must be None or datetime.tzinfo object (not %s)' % type(to_timezone) if not value.tzinfo: if not from_timezone: from_timezone = dateutil.tz.tzlocal()