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

R

richard

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
'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
 
P

Peter Hansen

richard said:
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
 
R

richard

Peter said:
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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,900
Latest member
Nell636132

Latest Threads

Top