From d09eb5e6348ffba76454df871f91d9cd15c20635 Mon Sep 17 00:00:00 2001 From: Florian Fischer Date: Sun, 12 Jul 2026 13:58:31 +0200 Subject: js: introduce common date formatting helpers --- cockpit/js/cockpit.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'cockpit') diff --git a/cockpit/js/cockpit.js b/cockpit/js/cockpit.js index 15219cd..1624742 100644 --- a/cockpit/js/cockpit.js +++ b/cockpit/js/cockpit.js @@ -17,6 +17,8 @@ import { isTeacher as getIsTeacher, getName, getUserId, + DATE_FMT, + DATETIME_FMT, } from "../../js/utils-ENV.js"; import { initSelection } from "../../js/selection.js"; @@ -259,11 +261,7 @@ async function updateStudentGraduation() { } const value = change[key]; - let fmt = ""; - if (key == "date") - fmt = `${value.getDate()}.${value.getMonth()}.${value.getFullYear()} ${value.getHours()}:${value.getMinutes()}`; - else - fmt = value; + const fmt = key == "date" ? DATETIME_FMT.format(value) : value; const changeTd = document.createElement("td"); changeTd.innerHTML = fmt; @@ -319,8 +317,8 @@ async function updateStudentGraduation() { for (const period of graduation.pastObservations) { const tr = document.createElement("tr"); const periodTd = document.createElement("td"); - const startDate = new Intl.DateTimeFormat("de-DE", { month: "numeric", day: "numeric" }).format(period.start); - const endDate = new Intl.DateTimeFormat("de-DE", { month: "numeric", day: "numeric", year: "numeric" }).format(period.end); + const startDate = DATE_FMT.format(period.start); + const endDate = DATE_FMT.format(period.end); periodTd.innerHTML = `${startDate} - ${endDate}`; tr.appendChild(periodTd); -- cgit v1.2.3