project setup

This commit is contained in:
Sone
2025-11-02 10:08:56 +01:00
commit 568838003e
174 changed files with 27100 additions and 0 deletions
+42
View File
@@ -0,0 +1,42 @@
import { format, isSameWeek } from "date-fns";
export const formatTime = (dateInput: string | Date | null | undefined) => {
if (!dateInput) return "";
const date = typeof dateInput === 'string' ? new Date(dateInput) : dateInput;
return format(date, "HH:mm");
};
export const formatDate = (dateInput: string | Date | null | undefined) => {
if (!dateInput) return "";
const date = typeof dateInput === 'string' ? new Date(dateInput) : dateInput;
const now = new Date();
if (
date.getDate() === now.getDate() &&
date.getMonth() === now.getMonth() &&
date.getFullYear() === now.getFullYear()
) {
return "Today";
}
const tomorrow = new Date(now);
tomorrow.setDate(now.getDate() + 1);
if (
date.getDate() === tomorrow.getDate() &&
date.getMonth() === tomorrow.getMonth() &&
date.getFullYear() === tomorrow.getFullYear()
) {
return "Tomorrow";
}
if (isSameWeek(date, now, { weekStartsOn: 1 })) {
return format(date, "EEEE");
}
return format(date, "dd/MM");
};
export const formatDateMDY = (dateInput: string | Date | null | undefined) => {
if (!dateInput) return "";
const date = typeof dateInput === 'string' ? new Date(dateInput) : dateInput;
return format(date, "MM/dd/yyyy");
};