rfc822 date header

M.-A. Lemburg mal at lemburg.com
Tue Apr 13 11:46:39 EDT 1999


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/  :
           ---------------------------------------------------------





More information about the Python-list mailing list