Files
Moonbase/src/lib/utils.ts

23 lines
609 B
TypeScript

import { type ClassValue, clsx } from "clsx";
import { twMerge } from "tailwind-merge";
export function cn(...inputs: ClassValue[]) {
return twMerge(clsx(inputs));
}
export function initials(name: string): string {
return name
.split(/\s+/)
.map((p) => p[0])
.filter(Boolean)
.slice(0, 2)
.join("")
.toUpperCase();
}
export function formatDate(date: Date | string | null | undefined): string {
if (!date) return "—";
const d = typeof date === "string" ? new Date(date) : date;
return d.toLocaleDateString("en-US", { month: "short", day: "numeric", year: "numeric" });
}