On 2016-01-15 13:44, Tomas Babej wrote:
> Hi,
> For the dates older than 1900, Python is unable to convert the datetime
> representation to string using strftime:
> https://bugs.python.org/issue1777412
> Work around the issue adding a custom method to convert the datetime
> objects to LDAP generalized time strings.
> https://fedorahosted.org/freeipa/ticket/5579

I noticed that all previous strftime() calls and the new code ignore any
time zone information. This isn't an issue for tz-naive datetime object
that don't have any time zone information attached. You can't fix them
anyway and just hope they are always UTC. For tz-aware datetime object
your approach returns the wrong value.

You can use datetime.utctimetuple() instead. The method returns a time
tuple in UTC.

>>> value
datetime.datetime(2016, 1, 18, 8, 2, 49, 646270)


Attachment: signature.asc
Description: OpenPGP digital signature

Manage your subscription for the Freeipa-devel mailing list:
Contribute to FreeIPA: http://www.freeipa.org/page/Contribute/Code

Reply via email to