aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cockpit/js/cockpit.js12
-rw-r--r--js/utils-mock.js1
-rw-r--r--js/utils-prod.js2
-rw-r--r--mass-graducation/src/main.js4
4 files changed, 10 insertions, 9 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);
diff --git a/js/utils-mock.js b/js/utils-mock.js
index c4a9a73..f394183 100644
--- a/js/utils-mock.js
+++ b/js/utils-mock.js
@@ -1,4 +1,5 @@
import { fetchStudent } from "./student-ENV.js";
+export { DATE_FMT, DATETIME_FMT, dateStringNow, datetimeStringNow } from "./utils-common.js";
export function isTeacher() {
return !(new URLSearchParams(document.location.search)).has("student");
diff --git a/js/utils-prod.js b/js/utils-prod.js
index 24bef96..70e4980 100644
--- a/js/utils-prod.js
+++ b/js/utils-prod.js
@@ -1,3 +1,5 @@
+export { DATE_FMT, DATETIME_FMT, dateStringNow, datetimeStringNow } from "./utils-common.js";
+
export function isTeacher() {
return Boolean(document.querySelector('.editmode-switch-form'))
|| document.body.classList.contains('editing');
diff --git a/mass-graducation/src/main.js b/mass-graducation/src/main.js
index 3d20f0b..8d009b0 100644
--- a/mass-graducation/src/main.js
+++ b/mass-graducation/src/main.js
@@ -8,7 +8,7 @@ import {
import { fetchGroups } from "../../js/group.js";
import { initSelection } from "../../js/selection.js";
-import { getName } from "../../js/utils-ENV.js";
+import { getName, DATETIME_FMT, datetimeStringNow } from "../../js/utils-ENV.js";
let group;
let name;
@@ -199,7 +199,7 @@ async function loadGroup(selected) {
} else {
date = graduation.observation.start;
}
- dateCell.innerHTML = date.toLocaleString("de-DE", { month: "numeric", day: "numeric", year: "numeric", hour: "numeric", minute: "numeric" });
+ dateCell.innerHTML = DATETIME_FMT.format(date);
row.appendChild(dateCell);
const btnCell = document.createElement("td");