From a3627f298f79ce376d22fdd05dad15a88809f6a0 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Fr=C3=A9d=C3=A9ric=20P=C3=A9ters?= Date: Sun, 20 Feb 2022 16:10:28 +0100 Subject: [PATCH] stamina: handle absence of nonstop zone at midnight --- nonstop/management/commands/stamina.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/nonstop/management/commands/stamina.py b/nonstop/management/commands/stamina.py index 68cbe63..a7595ff 100644 --- a/nonstop/management/commands/stamina.py +++ b/nonstop/management/commands/stamina.py @@ -515,7 +515,9 @@ class Command(BaseCommand): try: self.slot = [x for x in nonstops if x.start < now.time()][-1] except IndexError: - self.slot = nonstops[0] + # no slots starting at midnight, and time is midnight, get latest zone, + # as it will span midnight. + self.slot = nonstops[-1] try: next_slot = nonstops[nonstops.index(self.slot) + 1] except IndexError: -- 2.39.2