Corrections to last_end_time made to correctly calculate and display graphs on days where the sleep from the previous day did not cross over midnight. resolves babybuddy/babybuddy#554

This commit is contained in:
Gary Glatfelter 2022-10-30 17:43:03 -04:00 committed by Christopher Charbonneau Wells
parent 2e7dedea45
commit 6816349103
1 changed files with 4 additions and 0 deletions

View File

@ -64,6 +64,10 @@ def sleep_pattern(sleeps):
) )
duration = end_time - start_time duration = end_time - start_time
if last_end_time:
if last_end_time.date() < start_time.date():
last_end_time = start_time.replace(hour=0, minute=0, second=0)
if not last_end_time: if not last_end_time:
last_end_time = start_time.replace(hour=0, minute=0, second=0) last_end_time = start_time.replace(hour=0, minute=0, second=0)