Update Math on Cycle Length

This commit is contained in:
Alexander Hosking 2022-08-12 00:20:19 -04:00
parent 87f936c331
commit fa7d46623e

View File

@ -49,7 +49,7 @@ def create():
error = "You must provide a start date" error = "You must provide a start date"
if end_time > start_time: if end_time > start_time:
cycle_length = (end_time - start_time).days cycle_length = (end_time - start_time).days +1
else: else:
cycle_length = (pendulum.now() - start_time).days cycle_length = (pendulum.now() - start_time).days
@ -105,7 +105,7 @@ def update(id):
error = "You must provide a start date" error = "You must provide a start date"
if end_time > start_time: if end_time > start_time:
cycle_length = (end_time - start_time).days cycle_length = (end_time - start_time).days + 1
else: else:
cycle_length = (pendulum.now() - start_time).days cycle_length = (pendulum.now() - start_time).days
@ -154,7 +154,7 @@ def cycle_math():
if num > 0: if num > 0:
this_start = pendulum.parse(cycle['start_time']) this_start = pendulum.parse(cycle['start_time'])
next_start = pendulum.parse(all_cycles[num-1]['start_time']) next_start = pendulum.parse(all_cycles[num-1]['start_time'])
cycle_length = (next_start - this_start).days cycle_length = (next_start - this_start).days +1
db.execute( db.execute(
'UPDATE cycle SET cycle_length = ?' 'UPDATE cycle SET cycle_length = ?'
' WHERE id = ?', ' WHERE id = ?',