def parse_http_date(date):
MONTHS = '<STR_LIT>'.split()<EOL>__D = r'<STR_LIT>'<EOL>__D2 = r'<STR_LIT>'<EOL>__M = r'<STR_LIT>'<EOL>__Y = r'<STR_LIT>'<EOL>__Y2 = r'<STR_LIT>'<EOL>__T = r'<STR_LIT>'<EOL>RFC1123_DATE = re.compile(r'<STR_LIT>' % (__D, __M, __Y, __T))<EOL>RFC850_DATE = re.compile(r'<STR_LIT>' % (__D, __M, __Y2, __T))<EOL>ASCTIME_DATE = re.compile(r'<STR_LIT>' % (__M, __D2, __T, __Y))<EOL>for regex in RFC1123_DATE, RFC850_DATE, ASCTIME_DATE:<EOL><INDENT>m = regex.match(date)<EOL>if m is not None:<EOL><INDENT>break<EOL><DEDENT><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % date)<EOL><DEDENT>try:<EOL><INDENT>year = int(m.group('<STR_LIT>'))<EOL>if year < <NUM_LIT:100>:<EOL><INDENT>if year < <NUM_LIT>:<EOL><INDENT>year += <NUM_LIT><EOL><DEDENT>else:<EOL><INDENT>year += <NUM_LIT><EOL><DEDENT><DEDENT>month = MONTHS.index(m.group('<STR_LIT>').lower()) + <NUM_LIT:1><EOL>day = int(m.group('<STR_LIT>'))<EOL>hour = int(m.group('<STR_LIT>'))<EOL>min = int(m.group('<STR_LIT>'))<EOL>sec = int(m.group('<STR_LIT>'))<EOL>result = datetime.datetime(year, month, day, hour, min, sec)<EOL>return calendar.timegm(result.utctimetuple())<EOL><DEDENT>except Exception as exc:<EOL><INDENT>raise ValueError("<STR_LIT>" % date) from exc<EOL><DEDENT>
Parse a date format as specified by HTTP RFC7231 section 7.1.1.1.

The three formats allowed by the RFC are accepted, even if only the first
one is still in widespread use.

Return an integer expressed in seconds since the epoch, in UTC.

Implementation copied from Django.
https://github.com/django/django/blob/master/django/utils/http.py#L157
License: BSD 3-clause