parseCompactDate method
Converts the given compact date formatted string into a DateTime.
The format of the string must be a valid compact date format for the
given locale. If the text doesn't represent a valid date, null will be
returned.
See also:
- formatCompactDate, which will convert a DateTime into a string in the compact format.
Implementation
@override
HebrewDateTime? parseCompactDate(String? inputString) {
if (inputString == null) return null;
final parts = inputString.split('/');
if (parts.length != 3) return null;
final day = int.tryParse(parts[0].trim());
final month = int.tryParse(parts[1].trim());
final year = int.tryParse(parts[2].trim());
if (year == null ||
month == null ||
day == null ||
!HebrewDateTime.isValidDate(year, month, day)) {
return null;
}
return HebrewDateTime(year, month, day);
}