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()