[Baypiggies] HTTP date format

Alex Young alexander.young at gmail.com
Wed Feb 17 15:58:53 EST 2016


Something like this?

class GMT(tzinfo):
    def tzname(self, dt):
        return "GMT"

    def utcoffset(self, dt):
        return timedelta(0)

    def dst(self, dt):
        return timedelta(0)

datetime(1994, 11, 6, 8, 49, 37, 0, GMT()).strftime('%a, %d %b %Y %H:%M:%S
%Z')

'Sun, 06 Nov 1994 08:49:37 GMT'


On Wed, Feb 17, 2016 at 12:52 PM Fahrzin Hemmati via Baypiggies <
baypiggies at python.org> wrote:

> https://docs.python.org/2/library/email.util.html#email.utils.formatdate
> Set usegmt=True to get the right timezone string.
>
> On Wed, Feb 17, 2016 at 11:44 AM, Ian Zimmerman <itz at buug.org> wrote:
>
>> Is there a _simple_ way of formatting a date/time (in any of the
>> representations native to the Python standard library) in the format
>> specified by RFC 7231 [1]?
>>
>> I do not consider an implementation simple if it contains its own lists
>> of day and month names, such as [2] does.
>>
>> At some point, I will have to parse the format as well.
>>
>> [1]
>> https://tools.ietf.org/html/rfc7231#section-7.1.1.1
>>
>> [2]
>>
>> https://github.com/sam-washington/requests-aws4auth/blob/master/requests_aws4auth/aws4auth.py#L396
>>
>> --
>> 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:
>> https://mail.python.org/mailman/listinfo/baypiggies
>>
>
> _______________________________________________
> Baypiggies mailing list
> Baypiggies at python.org
> To change your subscription options or unsubscribe:
> https://mail.python.org/mailman/listinfo/baypiggies
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/baypiggies/attachments/20160217/dc9a5f3a/attachment.html>


More information about the Baypiggies mailing list