29 lines
928 B
TypeScript
29 lines
928 B
TypeScript
import { clsx, type ClassValue } from "clsx"
|
|
import { twMerge } from "tailwind-merge"
|
|
|
|
export function cn(...inputs: ClassValue[]) {
|
|
return twMerge(clsx(inputs))
|
|
}
|
|
|
|
export function dateToLocaleString(date: string) {
|
|
return new Date(date).toLocaleString("en-US",
|
|
{ timeZone: "Europe/Istanbul", hour12: false, year: "numeric", month: "2-digit", day: "2-digit", hour: "2-digit", minute: "2-digit", second: "2-digit" }
|
|
);
|
|
}
|
|
|
|
export function toISOIfNotZ(val: string): string {
|
|
if (val.endsWith("Z")) return val;
|
|
const [d, m, yAndTime] = val.split("/");
|
|
if (!yAndTime) return val;
|
|
const [y, time] = yAndTime.split(" ");
|
|
if (!time) return val;
|
|
const [h, min, s] = time.split(":").map(Number);
|
|
try {
|
|
const date = new Date(Number(y), Number(m) - 1, Number(d), h, min, s);
|
|
return date ? date.toISOString() : "";
|
|
} catch (error) {
|
|
console.error("Error converting date:", error);
|
|
return val;
|
|
}
|
|
}
|