From 68163491033b79a8c94fd38c455f6f9c93a948b5 Mon Sep 17 00:00:00 2001 From: Gary Glatfelter Date: Sun, 30 Oct 2022 17:43:03 -0400 Subject: [PATCH] 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 --- reports/graphs/sleep_pattern.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/reports/graphs/sleep_pattern.py b/reports/graphs/sleep_pattern.py index 435e14f6..bf9eddab 100644 --- a/reports/graphs/sleep_pattern.py +++ b/reports/graphs/sleep_pattern.py @@ -64,6 +64,10 @@ def sleep_pattern(sleeps): ) 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: last_end_time = start_time.replace(hour=0, minute=0, second=0)