remove the moment.js dependency

This commit is contained in:
njost
2024-03-15 23:21:13 +00:00
committed by ekresse
parent 7bb0af18c1
commit caefe2e475
3 changed files with 15 additions and 36 deletions

View File

@ -2,7 +2,6 @@
import { Ref, inject } from "vue";
import { Module } from "../model/module.ts";
import { Event } from "../model/event.ts";
import moment from "moment-timezone";
import { useI18n } from "vue-i18n";
const { t } = useI18n({ useScope: "global" });
@ -12,24 +11,27 @@ const dialogRef = inject("dialogRef") as any;
const module = dialogRef.value.data.module as Module;
const mobilePage = inject("mobilePage") as Ref<boolean>;
// formats 2023-10-26 11:45:00.000Z to DD-MM-YYYY HH:MM
function formatTimestamp(timestampString: string): string {
// Den übergebenen Zeitstempel in ein Moment-Objekt umwandeln
const timestamp = moment(timestampString);
// Die Zeitzone auf "Europe/Berlin" setzen
const berlinTime = timestamp.tz("Europe/Berlin");
// Das gewünschte Format für die Ausgabe festlegen
return berlinTime.format("DD.MM.YYYY HH:mm");
}
function sortModuleEventsByStart(events: Event[]) {
return events.sort((a, b) => {
return a.start.localeCompare(b.start);
});
}
const timeFormater = new Intl.DateTimeFormat("de-DE", {
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
hour12: false,
timeZone: "Europe/Berlin",
});
// formats 2023-10-26 11:45:00.000Z to DD-MM-YYYY HH:MM
function formatTimestamp(timestampString: string) {
return timeFormater.format(new Date(timestampString)).replace(",", "");
}
function formatWeekday(weekday: string) {
const template = "moduleInformation.weekday." + weekday;
const translation = t(template);