time.strftime() NOT producing RFC2822-compliant Date strings?

richard richardjones at optushome.com.au
Thu Jan 12 21:33:55 EST 2006


I'm just dealing with a Roundup bug report in which it's pointed out that
time.strftime() doesn't produce RFC2822-compliant date strings when in a
locale other than "C".

My reading of the RFC says that indeed the only valid strings should be the
"C" locale strings:

day-name        =       "Mon" / "Tue" / "Wed" / "Thu" /
                        "Fri" / "Sat" / "Sun"

month-name      =       "Jan" / "Feb" / "Mar" / "Apr" /
                        "May" / "Jun" / "Jul" / "Aug" /
                        "Sep" / "Oct" / "Nov" / "Dec"

and there's no mention in the RFC of locale issues. The python standard
library makes this bold claim:

  ... a format for dates compatible with that specified in the RFC 2822
  Internet email standard. 6.1 

  >>> from time import gmtime, strftime
  >>> strftime("%a, %d %b %Y %H:%M:%S +0000", gmtime())
  'Thu, 28 Jun 2001 14:17:15 +0000'

which would appear to be true for the "C" locale but not for "pl_PL", for
example.


     Richard




More information about the Python-list mailing list