refactor: actualy use caching model in time segment

This commit is contained in:
2022-01-14 23:04:34 +01:00
parent 066a378cf7
commit 425663d19b

View File

@@ -34,22 +34,26 @@ class DisplaySegment:
class ClockSegment(DisplaySegment): class ClockSegment(DisplaySegment):
""" between 0600 and 0700 returns true time, then approximation """ """ between 0600 and 0700 returns true time, then approximation """
def _get_data_text(self): time_display = ""
def _get_data_text(self):
return f"Czas: {self.time_display}"
def update(self):
now = datetime.datetime.now() now = datetime.datetime.now()
if now.hour >= 6 and now.hour < 7: if now.hour >= 6 and now.hour < 7:
self.validity = 60 self.validity = 60
return f"{now.hour}:{now.minute}" self.time_display = f"{now.hour}:{now.minute}"
self.validity = 5*60 self.validity = 5*60
if now.minute >= 45: if now.minute >= 45:
return f"przed {now.hour+1}" self.time_display = f"przed {now.hour+1}"
elif now.minute >= 15: elif now.minute >= 15:
return f"wpół do {now.hour+1}" self.time_display = f"wpół do {now.hour+1}"
else: else:
return f"po {now.hour}" self.time_display = f"po {now.hour}"
class TrafficSegment(DisplaySegment): class TrafficSegment(DisplaySegment):