mirror of
https://expo.survex.com/repositories/troggle/.git
synced 2024-11-25 08:41:51 +00:00
Correct and validate JSON dates when they are read from file
This commit is contained in:
parent
71bd07e70e
commit
86ea33bbce
@ -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():
|
||||
|
Loading…
Reference in New Issue
Block a user