in elastic/shared/utils/time.py [0:0]
def parse_interval(offset: str) -> Optional[timedelta]:
if not offset:
return None
match = re.match(r"^([+-]?\d+)([hmd])$", offset)
if match:
offset_amount = int(match.group(1))
if match.group(2) == "m":
return timedelta(minutes=offset_amount)
elif match.group(2) == "h":
return timedelta(hours=offset_amount)
elif match.group(2) == "d":
return timedelta(days=offset_amount)
else:
raise TimeParsingError(f"Invalid offset: {offset}")
else:
raise TimeParsingError(f"Invalid offset: {offset}")