mirror of
https://github.com/Noooste/garage-ui.git
synced 2026-08-11 05:56:55 +00:00
80553c6450
Signed-off-by: Noste <83548733+Noooste@users.noreply.github.com>
23 lines
618 B
TypeScript
23 lines
618 B
TypeScript
import { type ClassValue, clsx } from 'clsx';
|
|
import { twMerge } from 'tailwind-merge';
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs));
|
|
}
|
|
|
|
export function formatDate(date: Date | string): string {
|
|
const d = typeof date === 'string' ? new Date(date) : date;
|
|
return new Intl.DateTimeFormat('en-US', {
|
|
year: 'numeric',
|
|
month: 'short',
|
|
day: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
}).format(d);
|
|
}
|
|
|
|
export function truncateString(str: string, maxLength: number): string {
|
|
if (str.length <= maxLength) return str;
|
|
return `${str.slice(0, maxLength)}...`;
|
|
}
|