def http_date_to_dt(http_date, obs_date=False):
 if (not obs_date):
  return strptime(http_date, '%a, %d %b %Y %H:%M:%S %Z')
 time_formats = ('%a, %d %b %Y %H:%M:%S %Z', '%a, %d-%b-%Y %H:%M:%S %Z', '%A, %d-%b-%y %H:%M:%S %Z', '%a %b %d %H:%M:%S %Y')
 for time_format in time_formats:
  try:
   return strptime(http_date, time_format)
  except ValueError:
   continue
 raise ValueError(('time data %r does not match known formats' % http_date))

def http_date_to_dt ( http_date , obs_date = False ) : if ( not obs_date ) : return strptime ( http_date , '%a, %d %b %Y %H:%M:%S %Z' ) time_formats = ( '%a, %d %b %Y %H:%M:%S %Z' , '%a, %d-%b-%Y %H:%M:%S %Z' , '%A, %d-%b-%y %H:%M:%S %Z' , '%a %b %d %H:%M:%S %Y' ) for time_format in time_formats : try : return strptime ( http_date , time_format ) except ValueError : continue raise ValueError ( ( 'time data %r does not match known formats' % http_date ) )
converts an http date string to a datetime instance .