str2timedelta(value)

Parse a string into a timedelta.

Supports formats like:

  • “5d” (5 days)

  • “2h” (2 hours)

  • “30m” (30 minutes)

  • “45s” (45 seconds)

  • “1d 2h 30m” (combinations)

Parameters:

value (str) – The timedelta string to parse.

Raises:

ValueError – If the string format is not recognized.

Return type:

timedelta

Returns:

The parsed timedelta object.