Newer
Older
import dayjs from "dayjs";
const customParseFormat = require("dayjs/plugin/customParseFormat");
dayjs.extend(customParseFormat);
require("dayjs/locale/en");
require("dayjs/locale/de");
export function formatDateFromDB(date, locale) {
dayjs.locale(locale);
const d = dayjs(date);
return locale == "de" ? d.format("dd, DD.MM.YY") : d.format("ddd, DD.MM.YY");
}
export function formatTimeFromDB(startTime, endTime) {
const s = dayjs(startTime);
const e = dayjs(endTime);
return s.format("HH:mm") + " – " + e.format("HH:mm");
const now = new Date();
now.setDate(now.getDate() - 1);
return event.date > now.toISOString();