From 8d31ab763d16015e53d886ee658b82a0a157eaeb Mon Sep 17 00:00:00 2001 From: Philip Sargent Date: Sat, 9 Jul 2022 01:30:49 +0300 Subject: [PATCH] improve date parse eror messages --- parsers/logbooks.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/parsers/logbooks.py b/parsers/logbooks.py index 9d1a8f0..bcd81b3 100644 --- a/parsers/logbooks.py +++ b/parsers/logbooks.py @@ -179,7 +179,7 @@ def ParseDate(tripdate, year): mdategoof = re.match(r"(\d\d?)/0?(\d)/(20|19)?(\d\d)", tripdate) if mdatestandard: if not (mdatestandard.group(1) == year): - message = " ! - Bad date (year) in logbook: " + tripdate + " - " + year + message = f" ! - Bad date (year) in logbook: {tripdate} - {year}" DataIssue.objects.create(parser='logbooks', message=message) logdataissues["tripdate"]=message return datetime.date('1970', '01', '01') @@ -195,16 +195,16 @@ def ParseDate(tripdate, year): yadd = int(year[:2]) * 100 day, month, year = int(mdategoof.group(1)), int(mdategoof.group(2)), int(mdategoof.group(4)) + yadd else: - message = " ! - Bad date in logbook: " + tripdate + " - " + year + message = f" ! - Bad date in logbook: {tripdate} - {year}" DataIssue.objects.create(parser='logbooks', message=message) logdataissues["tripdate"]=message return date(year, month, day) except: - message = " ! - Failed to parse date in logbook: " + tripdate + " - " + year + message = f" ! - Failed to parse date in logbook: {tripdate} - {year}" DataIssue.objects.create(parser='logbooks', message=message) logdataissues["tripdate"]=message - return date(year, month, day) + return date('1970', '01', '01') # (2006 - not any more), 2008 - 2009 def Parselogwikitxt(year, expedition, txt):