parse static method
Parses a string representation of a DateTime range.
The input string should be in one of the following formats:
- [DateTime,DateTime] (inclusive start and end)
- [DateTime,DateTime) (inclusive start, exclusive end)
- (DateTime,DateTime] (exclusive start, inclusive end)
- (DateTime,DateTime) (exclusive start and end)
- (-infinity,infinity) (open range)
- (-infinity,DateTime] or (-infinity,DateTime) (open start, inclusive/exclusive end)
- [DateTime,infinity) or (DateTime,infinity) (inclusive/exclusive start, open end)
Returns a DateTimeRange instance if the input is valid, otherwise returns null.
Implementation
static DateTimeRange? parse(String? input, {bool? startInclusive, bool? endInclusive}) {
final range = Range._parse<DateTime>(input,
regexInfInf: regexInfInf,
regexInfVal: regexInfVal,
regexValInf: regexValInf,
regexValVal: regexValVal,
parser: (val) => DateTime.parse(val),
ctor: () => DateTimeRange._(),
startInclusive: startInclusive,
endInclusive: endInclusive) as DateTimeRange?;
return range;
}