Support short dates
This commit is contained in:
@@ -46,18 +46,20 @@ Future<BaseExpenseInfo?> extractInfoFromBill({
|
||||
|
||||
// Check for highestCost amount on invoice
|
||||
final dateRegexp = RegExp(
|
||||
r'([0-3][0-9])(\/|-)([0-1][0-9])(\/|-)(20[0-9]{2})',
|
||||
multiLine: true,
|
||||
r'([0-3][0-9])(\/|-)([0-1][0-9])(\/|-)((20|)[0-9]{2})',
|
||||
multiLine: false,
|
||||
caseSensitive: false,
|
||||
);
|
||||
final currDate = DateTime.now();
|
||||
DateTime? newest;
|
||||
for (final match in dateRegexp.allMatches(extractionResult.text)) {
|
||||
if (match.groupCount < 5) continue;
|
||||
if (match.groupCount < 6) continue;
|
||||
|
||||
int year = int.tryParse(match.group(6)!) ?? currDate.year;
|
||||
|
||||
try {
|
||||
final date = DateTime(
|
||||
int.tryParse(match.group(5)!) ?? currDate.year,
|
||||
year > 99 ? year : (2000 + year),
|
||||
int.tryParse(match.group(3)!) ?? currDate.month,
|
||||
int.tryParse(match.group(1)!) ?? currDate.day,
|
||||
);
|
||||
|
Reference in New Issue
Block a user