<div dir="ltr">Sorry to be 'that guy', but what is wrong with email.utils.formatdate? The docs even mention HTTP for why usegmt is there.</div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 17, 2016 at 1:28 PM, Ian Zimmerman <span dir="ltr"><<a href="mailto:itz@buug.org" target="_blank">itz@buug.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span class="">On 2016-02-17 20:58 +0000, Alex Young wrote:<br>
<br>
> datetime(1994, 11, 6, 8, 49, 37, 0, GMT()).strftime('%a, %d %b %Y %H:%M:%S<br>
> %Z')<br>
<br>
</span>Same trouble as always: I ask a question after thinking hard about a<br>
problem and seeing the difficulties, and I assume others see the<br>
difficulties as well :-(<br>
<br>
Here, the main difficulty (the one which made me stop hacking and ask)<br>
is that strftime is locale dependent, while the RFC demands fixed<br>
English spelling.<br>
<br>
In the meantime I came up with this pearl:<br>
<br>
def rfc7231_of_timestamp(timestamp):<br>
    real_loc = locale.getlocale(locale.LC_ALL)<br>
    locale.setlocale(locale.LC_ALL, 'C')<br>
    try:<br>
        gmtuple = time.gmtime(timestamp)<br>
        return time.strftime('%a, %d %b %Y %H:%M:%S', gmtuple) + ' GMT'<br>
    finally:<br>
        locale.setlocale(locale.LC_ALL, real_loc)<br>
<br>
Do you think it has a chance in hell of working?  Note: portability to<br>
Windows is not important, portability to MacOS only mildly interesting.<br>
<div class="HOEnZb"><div class="h5"><br>
--<br>
Please *no* private copies of mailing list or newsgroup messages.<br>
Rule 420: All persons more than eight miles high to leave the court.<br>
_______________________________________________<br>
Baypiggies mailing list<br>
<a href="mailto:Baypiggies@python.org">Baypiggies@python.org</a><br>
To change your subscription options or unsubscribe:<br>
<a href="https://mail.python.org/mailman/listinfo/baypiggies" rel="noreferrer" target="_blank">https://mail.python.org/mailman/listinfo/baypiggies</a><br>
</div></div></blockquote></div><br></div>