Burak Arslan <[email protected]> added the comment:
turns out timetuple was not passing timezone information. the correct way of
converting a datetime.datetime object to a correct rfc-2822 compliant date
string seems to be:
email.utils.formatdate(time.mktime(a.utctimetuple()) + 1e-6 * a.microsecond -
time.timezone)
what a mess. if the above is indeed the right way to do this, is it possible to
add the following function to the email.utils module?
def formatdatetime(dt_object):
return email.utils.formatdate(time.mktime(dt_object.utctimetuple()) + 1e-6
* a.microsecond - time.timezone)
this works for datetime instances both with and without time zone information.
ps: i updated the code in the github link but not here.
----------
_______________________________________
Python tracker <[email protected]>
<http://bugs.python.org/issue13284>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com