From aa19865be48abbde8da18517f9e0c0f29308e4cf Mon Sep 17 00:00:00 2001 From: Gogs Date: Tue, 14 Jul 2026 16:37:20 +0200 Subject: [PATCH] Local Timezone --- Dockerfile | 2 +- app/public/assets/js/modules/watchlist.js | 42 +++++++++++++++++++++-- app/public/index.php | 4 +++ 3 files changed, 45 insertions(+), 3 deletions(-) diff --git a/Dockerfile b/Dockerfile index d3c1f0b..64b7f74 100644 --- a/Dockerfile +++ b/Dockerfile @@ -7,7 +7,7 @@ RUN apt-get update \ ca-certificates \ && rm -rf /var/lib/apt/lists/* -RUN echo "memory_limit=512M" \ +RUN printf "memory_limit=512M\ndate.timezone=Europe/Vienna\n" \ > /usr/local/etc/php/conf.d/tvguide.ini COPY --from=composer:latest /usr/bin/composer /usr/bin/composer diff --git a/app/public/assets/js/modules/watchlist.js b/app/public/assets/js/modules/watchlist.js index 2d283e2..b0fb6e3 100644 --- a/app/public/assets/js/modules/watchlist.js +++ b/app/public/assets/js/modules/watchlist.js @@ -93,6 +93,36 @@ function getTimestamp(programme, type) { return Math.floor(parsedDate.getTime() / 1000); } +function formatLocalTime(timestamp) { + const value = Number(timestamp) || 0; + + if (!value) { + return ""; + } + + return new Date(value * 1000).toLocaleTimeString("de-AT", { + hour: "2-digit", + minute: "2-digit", + hour12: false + }); +} + +function formatLocalDate(timestamp) { + const value = Number(timestamp) || 0; + + if (!value) { + return ""; + } + + const date = new Date(value * 1000); + + const year = date.getFullYear(); + const month = String(date.getMonth() + 1).padStart(2, "0"); + const day = String(date.getDate()).padStart(2, "0"); + + return `${year}-${month}-${day}`; +} + function normalizeProgramme(programme) { const startTimestamp = getTimestamp(programme, "start"); @@ -106,6 +136,7 @@ function normalizeProgramme(programme) { ""; const startTime = + formatLocalTime(startTimestamp) || programme.start_time || ( typeof programme.start === "string" @@ -114,6 +145,7 @@ function normalizeProgramme(programme) { ); const stopTime = + formatLocalTime(stopTimestamp) || programme.stop_time || ( typeof programme.stop === "string" @@ -148,7 +180,10 @@ function normalizeProgramme(programme) { rating: programme.rating || "", country: programme.country || "", - date: programme.date || "", + date: + formatLocalDate(startTimestamp) || + programme.date || + "", start: startTime, stop: stopTime, @@ -202,7 +237,10 @@ function cleanupExpiredItems() { function getItems() { cleanupExpiredItems(); - return readItems().sort((a, b) => { + return readItems() + .map((item) => normalizeProgramme(item)) + .sort((a, b) => { + const startA = Number(a.start_timestamp) || Number.MAX_SAFE_INTEGER; diff --git a/app/public/index.php b/app/public/index.php index 5c97869..ed9c5a3 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -7,6 +7,10 @@ $config = new Config( '/var/www/config/channels.json' ); +date_default_timezone_set( + $config->get('timezone', 'Europe/Vienna') +); + $xmltv = new XmlTv( '/var/www/epg/guide.xml', $config->get('timezone', 'Europe/Vienna')