Initial commit

This commit is contained in:
2026-10-05 20:38:28 +02:00
commit 60a68b420e
107 changed files with 21716 additions and 0 deletions

View File

@@ -0,0 +1,35 @@
export function formatDuration(ms: number | null | undefined): string {
if (!ms || ms <= 0) return "--:--";
const total = Math.floor(ms / 1000);
const m = Math.floor(total / 60);
const s = total % 60;
return `${m}:${s.toString().padStart(2, "0")}`;
}
export function formatTime(seconds: number): string {
if (!Number.isFinite(seconds) || seconds < 0) seconds = 0;
const total = Math.floor(seconds);
const m = Math.floor(total / 60);
const s = total % 60;
return `${m}:${s.toString().padStart(2, "0")}`;
}
export function formatDate(value: string | null | undefined): string {
if (!value) return "";
const d = new Date(value);
if (Number.isNaN(d.getTime())) return value;
return d.toLocaleDateString("ru-RU", { year: "numeric", month: "long", day: "numeric" });
}
export function initials(name: string | null | undefined): string {
if (!name) return "?";
return name
.split(/\s+/)
.slice(0, 2)
.map((p) => p[0]?.toUpperCase() ?? "")
.join("");
}
export function cx(...parts: (string | false | null | undefined)[]): string {
return parts.filter(Boolean).join(" ");
}