Is there a fairly easy way to convert a datetime object into an RFC 1123 (HTTP/1.1) date/time string, i.e. a string with the format
Sun, 06 Nov 1994 08:49:37 GMT
Using strftime does not work, since the strings are locale-dependant. Do I have to build the string by hand?
You can use wsgiref.handlers.format_date_time from the stdlib which does not rely on locale settings
You can use email.utils.formatdate from the stdlib which does not rely on locale settings
If you can set the locale process wide then you can do:
If you don’t want to set the locale process wide you could use Babel date formating
A manual way to format it which is identical with wsgiref.handlers.format_date_time is: