forked from expo/troggle
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():
|
if not self.get_json():
|
||||||
return None
|
return None
|
||||||
jsondata = self.get_json()
|
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):
|
def people(self):
|
||||||
if not self.get_json():
|
if not self.get_json():
|
||||||
|
Loading…
x
Reference in New Issue
Block a user