If the arrival is due in > 99min, show the arrival time instead

This commit is contained in:
Nahuel Lofeudo 2023-04-23 06:32:26 +01:00
parent 2d00e744d6
commit 32b0fa3392
2 changed files with 10 additions and 1 deletions

View File

@ -1,3 +1,5 @@
import datetime
class ArrivalTime():
""" Represents the arrival times of buses at one of the configured stops """
@ -14,5 +16,12 @@ class ArrivalTime():
def isDue(self) -> bool:
return self.due_in_minutes < 1
def due_in_str(self) -> str:
if self.due_in_minutes < 99:
return str(self.due_in_minutes) + "min"
else:
due_in = datetime.datetime.now() + datetime.timedelta(0, self.due_in_seconds)
return due_in.strftime("%H:%M")
def __lt__(self, other) -> int:
return self.due_in_seconds < other.due_in_seconds

View File

@ -96,7 +96,7 @@ def update_screen(updates: list[ArrivalTime]) -> None:
line=line_num,
route=update.route_id,
destination=update.destination,
time_left='Due' if update.isDue() else f'{update.due_in_minutes}min',
time_left='Due' if update.isDue() else update.due_in_str(),
time_color=lcd_color
)