From 951dc38496b347aee7fc71d510a40bf5da0f0e9f Mon Sep 17 00:00:00 2001 From: Lili Date: Mon, 26 Sep 2022 16:51:44 +0200 Subject: [PATCH] redeem dashboard now shows in local timezone --- tlapbot/owncast_redeem_dashboard.py | 7 ++++++- tlapbot/templates/dashboard.html | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tlapbot/owncast_redeem_dashboard.py b/tlapbot/owncast_redeem_dashboard.py index df09ee2..27c7c64 100644 --- a/tlapbot/owncast_redeem_dashboard.py +++ b/tlapbot/owncast_redeem_dashboard.py @@ -1,6 +1,7 @@ from flask import render_template, Blueprint from tlapbot.db import get_db from tlapbot.owncast_helpers import pretty_redeem_queue +from datetime import datetime, timezone bp = Blueprint('redeem_dashboard', __name__) @@ -8,8 +9,12 @@ bp = Blueprint('redeem_dashboard', __name__) def dashboard(): queue = pretty_redeem_queue(get_db()) number_of_drinks = 0 + utc_timezone = timezone.utc if queue is not None: for row in queue: if row[1] == "drink": number_of_drinks += 1 - return render_template('dashboard.html', queue=queue, number_of_drinks=number_of_drinks) \ No newline at end of file + return render_template('dashboard.html', + queue=queue, + number_of_drinks=number_of_drinks, + utc_timezone=utc_timezone) \ No newline at end of file diff --git a/tlapbot/templates/dashboard.html b/tlapbot/templates/dashboard.html index 76c8250..163cf72 100644 --- a/tlapbot/templates/dashboard.html +++ b/tlapbot/templates/dashboard.html @@ -22,7 +22,7 @@ {% for row in queue %} - {{ row[0].time() }} + {{ row[0].replace(tzinfo=utc_timezone).astimezone().hour}}:{{row[0].replace(tzinfo=utc_timezone).astimezone().minute }} {{ row[1] }} {{ row[2] }}