From e6838a0c0f64ee7e6a7d9a4b9eb05c07a2b5d59c Mon Sep 17 00:00:00 2001 From: "Christopher C. Wells" Date: Sun, 11 Apr 2021 13:56:40 -0700 Subject: [PATCH] Correct sleep graph handling for entries that cross DST --- Pipfile | 1 + reports/graphs/sleep_pattern.py | 8 +++++--- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/Pipfile b/Pipfile index 14851a96..2c684401 100644 --- a/Pipfile +++ b/Pipfile @@ -25,3 +25,4 @@ uritemplate = "*" coveralls = "*" flake8 = "*" ipaddress = "*" +tblib = "*" diff --git a/reports/graphs/sleep_pattern.py b/reports/graphs/sleep_pattern.py index e7e67295..98c6671c 100644 --- a/reports/graphs/sleep_pattern.py +++ b/reports/graphs/sleep_pattern.py @@ -83,9 +83,11 @@ def sleep_pattern(instances): if start_time.utcoffset() != end_time.utcoffset(): diff = start_time.utcoffset() - end_time.utcoffset() duration -= timezone.timedelta(seconds=diff.seconds) - times[len(times) - 1] = duration.seconds/60 - labels[len(labels) - 1] = _format_label(duration, start_time, - end_time) + yesterday = (end_time - timezone.timedelta(days=1)) + yesterday = yesterday.date().isoformat() + times[yesterday][len(times[yesterday]) - 1] = duration.seconds/60 + labels[yesterday][len(times[yesterday]) - 1] = _format_label( + duration, start_time, end_time) last_end_time = end_time