Dupletten Logik optimiert
This commit is contained in:
@@ -52,11 +52,7 @@ function formatEventDay(value) {
|
||||
return "unbekannt";
|
||||
}
|
||||
|
||||
const normalizedValue =
|
||||
typeof value === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?$/.test(value)
|
||||
? `${value}Z`
|
||||
: value;
|
||||
const date = new Date(normalizedValue);
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return value;
|
||||
}
|
||||
@@ -68,20 +64,32 @@ function formatEventDay(value) {
|
||||
}).format(date);
|
||||
}
|
||||
|
||||
function formatEventTime(value) {
|
||||
function formatEventTime(value, source = "") {
|
||||
if (!value) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const normalizedValue =
|
||||
typeof value === "string" && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(\.\d+)?$/.test(value)
|
||||
? `${value}Z`
|
||||
: value;
|
||||
const date = new Date(normalizedValue);
|
||||
if (
|
||||
source?.startsWith("source:")
|
||||
&& typeof value === "string"
|
||||
&& /T(?:00|12):00(?::00(?:\.\d+)?)?(?:Z|[+-]\d{2}:\d{2})?$/.test(value)
|
||||
) {
|
||||
return "";
|
||||
}
|
||||
|
||||
const date = new Date(value);
|
||||
if (Number.isNaN(date.getTime())) {
|
||||
return "";
|
||||
}
|
||||
|
||||
if (
|
||||
source?.startsWith("source:")
|
||||
&& date.getMinutes() === 0
|
||||
&& (date.getHours() === 0 || date.getHours() === 12)
|
||||
) {
|
||||
return "";
|
||||
}
|
||||
|
||||
return new Intl.DateTimeFormat("de-DE", {
|
||||
hour: "2-digit",
|
||||
minute: "2-digit",
|
||||
@@ -362,7 +370,7 @@ function renderEvents() {
|
||||
<article class="event-card">
|
||||
<div class="event-date-badge">
|
||||
<strong>${escapeHtml(formatEventDay(event.event_date))}</strong>
|
||||
<span>${escapeHtml(formatEventTime(event.event_date) || "Zeit offen")}</span>
|
||||
<span>${escapeHtml(formatEventTime(event.event_date, event.source) || "Zeit offen")}</span>
|
||||
</div>
|
||||
<div class="event-content">
|
||||
<div class="event-header">
|
||||
|
||||
Reference in New Issue
Block a user