Skip to content

Instantly share code, notes, and snippets.

@neoshrew
Created December 15, 2016 12:07
Show Gist options
  • Save neoshrew/12beafc269e224a84186cc23e2be7b44 to your computer and use it in GitHub Desktop.
Save neoshrew/12beafc269e224a84186cc23e2be7b44 to your computer and use it in GitHub Desktop.
import datetime
import pytz
def rfc822_dt_format(dt):
assert isinstance(dt, datetime.datetime)
if dt.tzinfo is None:
dt.replace(tzinfo=pytz.utc)
return dt.strftime('%a, %d %b %Y %H:%M:%S %z')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment