duration_iso_string
Converts a timedelta object into an ISO 8601 formatted duration string, handling both positive and negative durations.
def duration_iso_string(
duration: datetime.timedelta
) - > string
Converts a timedelta object into an ISO 8601 formatted duration string, handling both positive and negative time offsets.
Parameters
| Name | Type | Description |
|---|---|---|
| duration | datetime.timedelta | The timedelta object representing the time span to be formatted. |
Returns
| Type | Description |
|---|---|
string | The ISO 8601 duration representation (e.g., 'P1DT02H30M00S') including a leading sign for negative durations. |