I'm writing a web-based email client in Python and a question has arisen about which time zone the "Date" header of an email should be represented as when sending.
RFC 2822 states in section 3.3 that:
The date and time-of-day SHOULD express local time.
This seems ambiguous to me; the question is the local time of who? The email server, or the sender? Naturally I'd assume the sender (who could be in any time zone, and can be changed in their account preferences). Further confusion arose when I looked Python's email.utils.formatdate function which seems to only offer two alternatives: UTC or local time (of the server). To me there doesn't appear to be any option of specifying an alternate timezone, or am I missing something?
Passing a timeval to formatdate using time.mktime(senders_tz_aware_now_datetime.timetuple())
results in a UTC date string, which feels wrong given what the RFC says above.
So which timezone should "Date" be, and does any standard function exist to create the appropriate date string?