]> git.0d.be Git - django-panik-nonstop.git/blobdiff - nonstop/management/commands/stamina.py
stamina: handle absence of nonstop zone at midnight
[django-panik-nonstop.git] / nonstop / management / commands / stamina.py
index 68cbe636f67be16c5eda13080dc4ecf55ec116b8..a7595ff1563d4b014ea51c4d191d9dfb6e396b71 100644 (file)
@@ -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: