Some fixes and additions

master
Davide Bongiovanni 5 years ago
parent 50c01cdf9d
commit a24d793287

@ -49,14 +49,19 @@ def getUpcomingMeals():
meals = []
for row in r:
meals.append(dict(row))
seconds_to_deadline = (parse(meals[-1]['selection_deadline']) - datetime.datetime.now()).seconds
print (meals)
print ('deadline ' + str(meals[-1]['selection_deadline'] ))
seconds_to_deadline = (meals[-1]['selection_deadline'] - datetime.datetime.now()).total_seconds()
print(str(seconds_to_deadline) + ' s to dead')
if seconds_to_deadline < 0:
meals[-1]['selection_deadline'] = 'Deadline passed'
else:
hours_td = round(seconds_to_deadline / 60 / 60)
days_td = hours_td / 24
elif seconds_to_deadline > 3600:
hours_td = round(seconds_to_deadline / 3600)
days_td = int(hours_td / 24)
hours_td = hours_td % 24
meals[-1]['selection_deadline'] = str(days_td) + ' days ' + str(hours_td)
meals[-1]['selection_deadline'] = str(days_td) + ' days ' + str(hours_td) + ' hours'
else:
meals[-1]['selection_deadline'] = str(round(seconds_to_deadline / 60)) + ' minutes'
r.close()
return meals

Loading…
Cancel
Save