2
0
mirror of https://expo.survex.com/repositories/troggle/.git synced 2024-11-25 16:51:54 +00:00

Correct and validate JSON dates when they are read from file

This commit is contained in:
Philip Sargent 2022-09-20 23:06:45 +03:00
parent 71bd07e70e
commit 86ea33bbce

View File

@ -239,7 +239,20 @@ class Wallet(models.Model):
if not self.get_json():
return None
jsondata = self.get_json()
return jsondata["date"]
datestr = jsondata["date"]
if not datestr:
return None
else:
datestr = datestr.replace('.','-')
try:
samedate = datetime.date.fromisoformat(datestr)
except:
try:
samedate = datetime.date.fromisoformat(datestr[:10])
except:
samedate = None
return samedate.isoformat()
def people(self):
if not self.get_json():