diff --git a/models/day.py b/models/day.py index ece5b14..699e206 100644 --- a/models/day.py +++ b/models/day.py @@ -1,6 +1,6 @@ from .channel import Channel from typing import List -from datetime import datetime +from datetime import datetime, timedelta, timezone from .programme import Programme @@ -20,6 +20,10 @@ def addProgram(self, prog: Programme): def getDate(self) -> str: return str(self.date) + def isToday(self) -> bool: + LOCAL_TIMEZONE = datetime.now(timezone(timedelta(0))).astimezone().tzinfo + return self.date == datetime.now(LOCAL_TIMEZONE).date() + def getWochentag(self) -> str: weekdays = {0: "Montag", 1: "Dienstag", diff --git a/models/programme.py b/models/programme.py index e3bd5a3..7dda8d3 100644 --- a/models/programme.py +++ b/models/programme.py @@ -1,14 +1,18 @@ -from datetime import datetime, timedelta +from datetime import datetime, timedelta, timezone from typing import Dict from .channelName import ChannelName +LOCAL_TIMEZONE = datetime.now(timezone(timedelta(0))).astimezone().tzinfo + class Programme: def __init__(self, channelName: ChannelName, start: datetime, stop: datetime): self.channelName: ChannelName = channelName date_format: str = "%Y%m%d%H%M%S %z" - self.start = datetime.strptime(start, date_format) + timedelta(hours=2) - self.stop = datetime.strptime(stop, date_format) + timedelta(hours=2) + + self.start = datetime.strptime(start, date_format).astimezone(LOCAL_TIMEZONE) + self.stop = datetime.strptime(stop, date_format).astimezone(LOCAL_TIMEZONE) + self.data: Dict = {} self.prominent = False if self.start.hour >= 20 and self.start.minute >= 1: @@ -16,6 +20,8 @@ def __init__(self, channelName: ChannelName, start: datetime, stop: datetime): if self.start.hour >= 21: self.prominent = True self.onPrevDay = False + now = datetime.now(LOCAL_TIMEZONE) + self.nowRunning = now >= self.start and now <= self.stop def startTime(self) -> str: return self.start.strftime("%H:%M") diff --git a/static/style.css b/static/style.css index 48cf82e..3d4c83c 100644 --- a/static/style.css +++ b/static/style.css @@ -65,6 +65,10 @@ body { display: inline; } +.nowRunning { + background-color: #ffffcc !important; +} + .prominent { /* https://stackoverflow.com/questions/17158253/indent-starting-from-the-second-line-of-a-paragraph-with-css */ padding-left: 1.5em; diff --git a/templates/hello.html b/templates/hello.html index 225b014..ec02772 100644 --- a/templates/hello.html +++ b/templates/hello.html @@ -11,7 +11,7 @@ {% for day in guide.days.items() %}