[Baypiggies] HTTP date format
fahhem at google.com
Wed Feb 17 17:19:54 EST 2016
Sorry to be 'that guy', but what is wrong with email.utils.formatdate? The
docs even mention HTTP for why usegmt is there.
On Wed, Feb 17, 2016 at 1:28 PM, Ian Zimmerman <itz at buug.org> wrote:
> On 2016-02-17 20:58 +0000, Alex Young wrote:
> > datetime(1994, 11, 6, 8, 49, 37, 0, GMT()).strftime('%a, %d %b %Y
> > %Z')
> Same trouble as always: I ask a question after thinking hard about a
> problem and seeing the difficulties, and I assume others see the
> difficulties as well :-(
> Here, the main difficulty (the one which made me stop hacking and ask)
> is that strftime is locale dependent, while the RFC demands fixed
> English spelling.
> In the meantime I came up with this pearl:
> def rfc7231_of_timestamp(timestamp):
> real_loc = locale.getlocale(locale.LC_ALL)
> locale.setlocale(locale.LC_ALL, 'C')
> gmtuple = time.gmtime(timestamp)
> return time.strftime('%a, %d %b %Y %H:%M:%S', gmtuple) + ' GMT'
> locale.setlocale(locale.LC_ALL, real_loc)
> Do you think it has a chance in hell of working? Note: portability to
> Windows is not important, portability to MacOS only mildly interesting.
> Please *no* private copies of mailing list or newsgroup messages.
> Rule 420: All persons more than eight miles high to leave the court.
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Baypiggies