def METHOD_NAME(timeStr: str) -> Optional[timedelta]:
	"""
	Attempts to convert a time string to a timedelta for a
	D HH:MM:SS, HH:MM:SS, MM:SS or SS -style interval.
	Note days D must be less than or equal to 31.
	"""
	timeStr = timeStr.strip()
	outputFormat = _getTimeOutputFormat(timeStr)
	if outputFormat is None:
		return None
	try:
		parsedTime = datetime.strptime(
			timeStr,
			_timeOutputToParsingFormats[outputFormat]
		)
	except ValueError:
		# Note if D > 31, strptime does not recognise that value for d.
		log.exception(f"Unexpected time format {timeStr}.")
		return None
	if outputFormat in (TimeOutputFormat.DAY, TimeOutputFormat.DAYS):
		parsedDay = parsedTime.day
	else:
		parsedDay = 0
	return timedelta(
		days=parsedDay,
		hours=parsedTime.hour,
		minutes=parsedTime.minute,
		seconds=parsedTime.second
	)