def _try_parse_datetime(time_str, fmts):
 result = None
 for fmt in fmts:
  try:
   result = datetime.strptime(time_str, fmt)
   break
  except ValueError:
   pass
 return result

def _try_parse_datetime ( time_str , fmts ) : result = None for fmt in fmts : try : result = datetime . strptime ( time_str , fmt ) break except ValueError : pass return result
attempts to parse the input time_str as a date .