code: def parse_date(date_str):
      
      if not date_str:
          return None
  
      try:
          date = ciso8601.parse_datetime(date_str)
          if not date:
              date = arrow.get(date_str).datetime
      except TypeError:
          date = arrow.get(date_str[0]).datetime
      return date
docs: Parse elastic datetime string.