From 6f55c6dff85513a81647d2b47afbbdf7fa3d7d7c Mon Sep 17 00:00:00 2001 From: Meik Date: Mon, 23 Feb 2026 16:42:33 +0100 Subject: [PATCH] Merge start/end dates into compact trade fair term column --- web/index.html | 3 +-- web/trade-fairs.js | 46 +++++++++++++++++++++++++++++++++++++++------- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/web/index.html b/web/index.html index f762d79..a246f8a 100644 --- a/web/index.html +++ b/web/index.html @@ -1575,8 +1575,7 @@ - - + diff --git a/web/trade-fairs.js b/web/trade-fairs.js index 5f52622..830d96b 100644 --- a/web/trade-fairs.js +++ b/web/trade-fairs.js @@ -24,8 +24,7 @@ 'thema', 'stadt', 'bundesland', - 'termin_start', - 'termin_ende', + 'termin', 'besucher', 'besucher_jahr', 'besucher_status', @@ -706,8 +705,7 @@ thema: 'text', stadt: 'text', bundesland: 'text', - termin_start: 'date', - termin_ende: 'date', + termin: 'date', besucher: 'number', besucher_jahr: 'number', besucher_status: 'text', @@ -763,7 +761,8 @@ return { ...row, tage_bis_start: getDaysUntil(row.termin_start), - zuletzt_gesucht_am: lastOpenedByTradeFair[getTradeFairOpenKey(row)] || null + zuletzt_gesucht_am: lastOpenedByTradeFair[getTradeFairOpenKey(row)] || null, + termin: row.termin_start || null }; } @@ -806,6 +805,40 @@ return date.toLocaleDateString('de-DE'); } + function formatTermRange(startIso, endIso) { + const start = toDate(startIso); + const end = toDate(endIso); + + if (!start && !end) { + return 'k.A.'; + } + if (start && !end) { + return formatDate(startIso); + } + if (!start && end) { + return formatDate(endIso); + } + + const startDay = start.getDate(); + const startMonth = start.getMonth() + 1; + const startYear = start.getFullYear(); + const endDay = end.getDate(); + const endMonth = end.getMonth() + 1; + const endYear = end.getFullYear(); + + if (startYear === endYear) { + if (startMonth === endMonth) { + if (startDay === endDay) { + return `${startDay}.${startMonth}.${startYear}`; + } + return `${startDay}.-${endDay}.${startMonth}.${startYear}`; + } + return `${startDay}.${startMonth}.-${endDay}.${endMonth}.${startYear}`; + } + + return `${startDay}.${startMonth}.${startYear}-${endDay}.${endMonth}.${endYear}`; + } + function matchesSearch(row, term) { if (!term) { return true; @@ -1523,8 +1556,7 @@ thema: createCell(row.thema, 'thema'), stadt: createCell(row.stadt, 'stadt'), bundesland: createCell(row.bundesland, 'bundesland'), - termin_start: createCell(formatDate(row.termin_start), 'termin_start'), - termin_ende: createCell(formatDate(row.termin_ende), 'termin_ende'), + termin: createCell(formatTermRange(row.termin_start, row.termin_ende), 'termin'), besucher: createCell(formatNumber(row.besucher), 'besucher'), besucher_jahr: createCell(formatNumber(row.besucher_jahr), 'besucher_jahr'), besucher_status: createCell(row.besucher_status, 'besucher_status'),