/
dafaqtx
/
threads-clone
Обзор
Документация
Войти
/
dafaqtx
/
threads-clone
Код
Запросы
0
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
main
lib/utils.ts
40 строк
1 KB
Alexander Kuchuk
made frontend part
06 авг 2023, 18:24
06 авг 2023, 18:24
b4ed5c9
Код
Авторство
О чём код?
import { clsx, type ClassValue } from "clsx"; import { twMerge } from "tailwind-merge"; // generated by shadcn export function cn(...inputs: ClassValue[]) { return twMerge(clsx(inputs)); } export function isBase64Image(imageData: string): boolean { const base64Regex = /^data:image\/(png|jpe?g|gif|webp);base64,/; return base64Regex.test(imageData); } export function formatDateString(dateString: string): string { const options: Intl.DateTimeFormatOptions = { year: "numeric", month: "short", day: "numeric", }; const date = new Date(dateString); const formattedDate = date.toLocaleDateString(undefined, options); const time = date.toLocaleTimeString([], { hour: "numeric", minute: "2-digit", }); return `${time} - ${formattedDate}`; } export function formatThreadCount(count: number): string { if (count === 0) { return "No Threads"; } else { const threadCount = count.toString().padStart(2, "0"); const threadWord = count === 1 ? "Thread" : "Threads"; return `${threadCount} ${threadWord}`; } }