diff options
| author | Florian Fischer <florian.fischer@muhq.space> | 2026-07-12 13:58:31 +0200 |
|---|---|---|
| committer | Florian Fischer <florian.fischer@muhq.space> | 2026-07-12 13:58:31 +0200 |
| commit | d09eb5e6348ffba76454df871f91d9cd15c20635 (patch) | |
| tree | 4aef8afe9d8a611919ebd33405a6e03e79961da4 /cockpit | |
| parent | 1a291fb37fdf0e5a1b2a54825e5af7c5e986f00f (diff) | |
| download | bycs-sol-d09eb5e6348ffba76454df871f91d9cd15c20635.tar.gz bycs-sol-d09eb5e6348ffba76454df871f91d9cd15c20635.zip | |
js: introduce common date formatting helpers
Diffstat (limited to 'cockpit')
| -rw-r--r-- | cockpit/js/cockpit.js | 12 |
1 files changed, 5 insertions, 7 deletions
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); |
