parse static method
Parses the ISO 8601 - Duration. If the operation was not successful then it throws FormatException.
Usage example:
IsoDuration.parse('P5Y'); // IsoDuration{years: 5, months: 0, weeks: 0, days: 0, hours: 0, minutes: 0, seconds: 0};
IsoDuration.parse('P3Y6M4DT12H30M5S'); // IsoDuration{years: 3, months: 6, weeks: 0, days: 4, hours: 12, minutes: 30, seconds: 5};
can parse also decimal:
IsoDuration.parse('PT8M40.215S'); // IsoDuration{years: 0, months: 0, weeks: 0, days: 0, hours: 0, minutes: 8, seconds: 40.215};
See also:
Implementation
static IsoDuration parse(String input) {
final parsed = tryParse(input);
if (parsed != null) {
return parsed;
}
throw FormatException('Could not parse the ISO Duration: $input');
}