gui: work in progress

This commit is contained in:
Carl-Gerhard Lindesvärd
2023-10-17 21:47:37 +02:00
parent b9fe6127ff
commit 206ae54dea
53 changed files with 2632 additions and 88 deletions

View File

@@ -0,0 +1,27 @@
import { type IInterval } from "@/types";
export function formatDateInterval(interval: IInterval, date: Date): string {
if (interval === "hour") {
return new Intl.DateTimeFormat("en-GB", {
hour: "2-digit",
minute: "2-digit",
}).format(date);
}
if (interval === "month") {
return new Intl.DateTimeFormat("en-GB", { month: "short" }).format(date);
}
if (interval === "day") {
return new Intl.DateTimeFormat("en-GB", { weekday: "short" }).format(
date,
);
}
return date.toISOString();
}
export function useFormatDateInterval(interval: IInterval) {
return (date: Date | string) => formatDateInterval(interval, typeof date === "string" ? new Date(date) : date);
}