mirror of
https://gitlab.dit.htwk-leipzig.de/htwk-software/htwkalender-pwa.git
synced 2025-07-16 09:38:51 +02:00
remove the moment.js dependency
This commit is contained in:
@ -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);
|
||||
|
Reference in New Issue
Block a user