Period.of_duration#
- static Period.of_duration(duration)[source]#
Return a Period from an (extended) ISO 8601 duration string
Both plain and extended (“+offset”) ISO 8601 duration strings are supported; the extended form is tried first.
- Parameters:
duration (
str) – An ISO 8601 duration string e.g. “P1Y” or “PT15M”, or with offset e.g. “P1D+T9H”- Return type:
- Returns:
A Period object defined by the supplied (extended) ISO 8601 duration string
- Raises:
PeriodParsingError – If the string does not contain a valid (extended) ISO 8601 duration value.