LdapServer: fix formating naive date/datetime
This commit is contained in:
parent
6830447f96
commit
35187aebdf
1 changed files with 1 additions and 1 deletions
|
@ -365,7 +365,7 @@ def format_datetime(value, from_timezone=None, to_timezone=None, naive=None):
|
||||||
to_timezone = dateutil.tz.tzlocal()
|
to_timezone = dateutil.tz.tzlocal()
|
||||||
elif isinstance(to_timezone, str):
|
elif isinstance(to_timezone, str):
|
||||||
to_timezone = pytz.timezone(to_timezone)
|
to_timezone = pytz.timezone(to_timezone)
|
||||||
to_value = from_value.astimezone(to_timezone)
|
to_value = from_value.astimezone(to_timezone) if not naive else from_value
|
||||||
datestring = to_value.strftime('%Y%m%d%H%M%S%z')
|
datestring = to_value.strftime('%Y%m%d%H%M%S%z')
|
||||||
if datestring.endswith('+0000'):
|
if datestring.endswith('+0000'):
|
||||||
datestring = datestring.replace('+0000', 'Z')
|
datestring = datestring.replace('+0000', 'Z')
|
||||||
|
|
Loading…
Reference in a new issue