﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
3554	[patch] implement explicit timezone offset in date header for emails generated by django	mrmachine <real dot human at mrmachine dot net>	Adrian Holovaty	"django.core.mail uses formatdate() from the rfc822 module which has been deprecated as of python 2.3 in favour of the email module (http://docs.python.org/lib/module-rfc822.html), which contains an equivelent Utils.formatdate() method.

the problem with rfc822.formatdate() is that it includes the timezone offset as a named string which some popular MUA's misread or ignore (such as apple's mail.app), causing emails generated by django to appear out of order as the date header is assumed to be local time when it is actually GMT.

{{{
>>> import rfc822       
>>> from email import Utils
>>> rfc822.formatdate()
'Fri, 23 Feb 2007 00:16:54 GMT'
>>> Utils.formatdate()
'Fri, 23 Feb 2007 00:17:01 -0000'
}}}

RFC822 was made obsolete by RFC2822 (http://www.faqs.org/rfcs/rfc2822.html) which states:

{{{
The zone specifies the offset from Coordinated Universal Time (UTC,
formerly referred to as ""Greenwich Mean Time"") that the date and
time-of-day represent.  The ""+"" or ""-"" indicates whether the
time-of-day is ahead of (i.e., east of) or behind (i.e., west of)
Universal Time.  The first two digits indicate the number of hours
difference from Universal Time, and the last two digits indicate the
number of minutes difference from Universal Time.  (Hence, +hhmm
means +(hh * 60 + mm) minutes, and -hhmm means -(hh * 60 + mm)
minutes).  The form ""+0000"" SHOULD be used to indicate a time zone at
Universal Time.  Though ""-0000"" also indicates Universal Time, it is
used to indicate that the time was generated on a system that may be
in a local time zone other than Universal Time and therefore
indicates that the date-time contains no information about the local
time zone.
}}}

email.Utils.formatdate() always returns the current Universal Time regardless of local server time with ""-0000"" as the timezone, which is correct according to the RFC above. attached is a patch which replaces rfc822.formatdate() with email.Utils.formatdate() in django.core.mail. it's a simple change which shouldn't break anything, but should improve compatibility with MUA's which don't understand or choose to ignore named timezones and expect an explicit offset instead.
"		closed	Core (Mail)	dev		fixed	mail timezone rfc822 rfc2822	real.human@…	Ready for checkin	1	0	0	0	0	0
