docs: def parse_date(date, date_format=None):
  
          """Convert a date to ISO8601 date format
          input format: YYYY-MM-DD HH:MM:SS GMT (works less reliably for other TZs)
          or            YYYY-MM-DD HH:MM:SS.0
          or            YYYY-MM-DD
          or            epoch (13 digit, indicating ms)
          or            epoch (10 digit, indicating sec)
          output format: iso8601"""
          date = date.strip()
  
          if date_format:
              try:
                  if date_format.find('%Z') != -1:
                      date_format = date_format.replace('%Z', '')
                      match_object = re.search('(([-+])(\d{2})(\d{2}))', date)
                      if match_object is None:
                          match_object = re.search('(([-+])(\d{2}):(\d{2}))', date)
                      tz = match_object.groups()
  
                      dt = datetime.strptime(date.replace(tz[0], ''), date_format)
                      delta = timedelta(hours=int(tz[2]), minutes=int(tz[3]))
                      if tz[1] == '-': delta = delta * -1
                      dt = dt + delta
  
                      return dt
  
                  return datetime.strptime(date, date_format)
              except Exception:
                  pass
  
          try:
              return datetime.strptime(date, "%Y-%m-%d %H:%M:%S")
          except:
              pass
  
          try:
              # Friday, October 2, 2015 1:35 AM
              return datetime.strptime(date, "%A, %B %d, %Y %I:%M %p")
          except:
              pass
  
          try:
              # Friday, 2 October 2015, 18:23
              return datetime.strptime(date, "%A, %d %B %Y, %H:%M")
          except:
              pass
  
          try:
              # Thu October 01st, 2015
              return datetime.strptime(date, "%a %B %dst, %Y")
          except:
              pass
  
          try:
              # Thu October 02nd, 2015
              return datetime.strptime(date, "%a %B %dnd, %Y")
          except:
              pass
  
          try:
              # Thu October 03rd, 2015
              return datetime.strptime(date, "%a %B %drd, %Y")
          except:
              pass
  
          try:
              # Thu October 04th, 2015
              return datetime.strptime(date, "%a %B %dth, %Y")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%Y-%m-%d %H:%M:%S %Z")
          except Exception:
              pass
  
          try:
              return datetime.strptime(date, "%A, %b %d, %Y")
          except Exception:
              pass
  
          try:
              return datetime.strptime(date, "%Y-%m-%d %H:%M:%S.0")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%Y-%m-%d")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%b %d, %Y")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%B %d, %Y")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%B %d, %Y %I:%M %p")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%b %d, %Y at %I:%M %p")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%m-%d-%Y")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%Y-%m-%dT%H:%M:%S")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%fZ")
          except:
              pass
  
          try:
              return datetime.strptime(date, "%Y-%m-%dT%H:%M:%S.%f+00:00")
          except:
              pass
  
          try:
              date = int(date)
              if 1000000000000 < date < 9999999999999:
                  # 13 digit epoch
                  return datetime.fromtimestamp(mktime(gmtime(date / 1000)))
          except:
              pass
  
          try:
              date = int(date)
              if 1000000000 < date < 9999999999:
                  # 10 digit epoch
                  return datetime.fromtimestamp(mktime(gmtime(date)))
          except:
              pass
          # If all else fails, return empty
          return None