By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
458,122 Members | 1,559 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 458,122 IT Pros & Developers. It's quick & easy.

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

P: n/a
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

Jan 13 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
richard wrote:
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".


While it doesn't fix strftime() (though a change to the docs might do
that <wink>), using email.Utils.formatdate() appears likely to fix your
immediate problem, not to mention looking cleaner.

-Peter

Jan 13 '06 #2

P: n/a
Peter Hansen wrote:
richard wrote:
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".


While it doesn't fix strftime() (though a change to the docs might do
that <wink>), using email.Utils.formatdate() appears likely to fix your
immediate problem, not to mention looking cleaner.


Yeah, of course I only thought of the email module *after* I hit the send
button :)

Roundup was started in the 2.0 days of Python, with 1.5.2-compatibility a
big requirement back then, so the email module hasn't really factored into
its development until "relatively recently" :)
Richard

Jan 13 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.