strftime: %Z, timezone, and all that

Les Schaffer schaffer at optonline.net
Wed Jun 27 00:04:10 EDT 2001


i tried adding a date header to an email as per the python docs, like so:

def _dateStamp():
    """Stamp an rfc-8222 compilant date for the header."""
    
    return strftime("%a, %d %b %Y %H:%M:%S %Z", localtime())


this is what it looks like in the (outgoing) email file:

    Date: Tue, 26 Jun 2001 23:40:46 Eastern Daylight Time

and when i use smtplib to deliver da mail, the (received) date gets mangled
like so:

    Date: Tue, 26 Jun 2001 23:40:46 +0000 (Eastern)

seems like %Z in strftime should either return a +0500 or an EDT, no?
the Python doc says this:

"""
Here is an example, a format for dates compatible with that specified in the
RFC 822 Internet email standard. 6.1 


>>> from time import *
>>> strftime("%a, %d %b %Y %H:%M:%S %Z", localtime())
'Sat, 27 Jan 2001 05:15:05 EST'
>>>
"""



les schaffer




More information about the Python-list mailing list