Period.parse constructor

Period.parse(
  1. String periodString
)

Parses an ISO 8601 period string.

Ignores the time portion of the string (if any).

Period.parse('P1Y2M3D') == Period(years: 1, months: 2, days: 3);
Period.parse('P1DT3S') == Period(days: 1);  // Ignores seconds.

Implementation

factory Period.parse(String periodString) {
  var fields = _parseIso8601Period(periodString);
  return Period(
      years: fields.years, months: fields.months, days: fields.days);
}