Local Timezone

This commit is contained in:
Gogs
2026-07-14 16:37:20 +02:00
parent 3ae2d14e95
commit aa19865be4
3 changed files with 45 additions and 3 deletions
+1 -1
View File
@@ -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
+40 -2
View File
@@ -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;
+4
View File
@@ -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')