carpenterParseDate function
Implementation
DateTime? carpenterParseDate(String value) {
final parts = value.split('.');
if (parts.length != 3) return null;
final day = int.tryParse(parts[0]);
final month = int.tryParse(parts[1]);
final year = int.tryParse(parts[2]);
if (day == null || month == null || year == null) return null;
if (year < 1 || month < 1 || month > 12 || day < 1) return null;
final candidate = DateTime(year, month, day);
if (candidate.year != year ||
candidate.month != month ||
candidate.day != day) {
return null;
}
return candidate;
}