parse_duration
Parse a duration string and return a datetime.timedelta.
The preferred format for durations in Django is '%d %H:%M:%S.%f'.
Also supports ISO 8601 representation (excluding years and months) and PostgreSQL's day-time interval format.
def parse_duration(
value: string
) - > datetime.timedelta
Parse a duration string and return a datetime.timedelta.
Parameters
| Name | Type | Description |
|---|---|---|
| value | string | The duration string to be parsed, supporting Django's preferred format, ISO 8601 (excluding years/months), and PostgreSQL interval formats |
Returns
| Type | Description |
|---|---|
datetime.timedelta | A timedelta object representing the parsed duration, or None if the input format is unrecognized |