wasm-demo/demo/ermis-f/python_m/cur/1138

51 lines
1.7 KiB
Plaintext

From: mal at lemburg.com (M.-A. Lemburg)
Date: Tue, 13 Apr 1999 15:46:39 GMT
Subject: rfc822 date header
References: <3712D863.2A8148BC@rubic.com> <3712F4C1.52327AF4@lemburg.com> <371318BC.E131EDF0@oratrix.com>
Message-ID: <371366DF.DE55B6@lemburg.com>
Content-Length: 1387
X-UID: 1138
Jack Jansen wrote:
>
> "M.-A. Lemburg" wrote:
> >
> > Jeff Bauer wrote:
> > >
> > > Is there a reasonably bulletproof way to generate an
> > > rfc822-compliant date header using the time module?
> > >
> > > The reason I ask is I recall a number of subtle
> > > errors in this regard, reported by Chris Lawrence,
> > > among others.
> >
> > According to the RFC, time.ctime() should do the trick...
> > but it's probably locale aware which the RFC doesn't account
> > for.
>
> Which RFC are you referring to? time.ctime() output is definitely *not*
> compatible with RFC822. But it should be easy enough to come up with a
> time.strftime() format that does the right thing...
Ah, sorry, I mixed up HTTP and RFC822. According to RFC 2068 (HTTP 1.1)
the result of time.asctime() is a valid date header.
Since time.ctime() is short for time.asctime(time.localtime(ticks))
it would not result in the correct value for HTTP either (:-/ second
Ooops). You'd have to use time.asctime(time.gmtime(ticks)).
Oh well. Anyway, mxDateTime does the right thing (and also allows
parsing those beasts).
Cheers,
--
Marc-Andre Lemburg Y2000: 262 days left
---------------------------------------------------------------------
: Python Pages >>> http://starship.skyport.net/~lemburg/ :
---------------------------------------------------------