vibe coded v1

This commit is contained in:
khannurien
2026-03-16 07:34:49 +00:00
parent 6207a7549f
commit e88fed4e98
48 changed files with 4303 additions and 595 deletions

5
src/utils/format.ts Normal file
View File

@@ -0,0 +1,5 @@
export function formatBytes(bytes: number): string {
if (bytes < 1024) return `${bytes} B`;
if (bytes < 1024 * 1024) return `${(bytes / 1024).toFixed(1)} KB`;
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
}

14
src/utils/relativeTime.ts Normal file
View File

@@ -0,0 +1,14 @@
const rtf = new Intl.RelativeTimeFormat("en", { numeric: "auto" });
export function relativeTime(dateStr: string): string {
const diff = new Date(dateStr).getTime() - Date.now(); // negative = past
const abs = Math.abs(diff) / 1000;
if (abs < 60) return rtf.format(-Math.round(abs), "second");
if (abs < 3600) return rtf.format(-Math.round(abs / 60), "minute");
if (abs < 86400) return rtf.format(-Math.round(abs / 3600), "hour");
if (abs < 7 * 86400) return rtf.format(-Math.round(abs / 86400), "day");
if (abs < 30 * 86400) return rtf.format(-Math.round(abs / 7 / 86400), "week");
if (abs < 365 * 86400) return rtf.format(-Math.round(abs / 30 / 86400), "month");
return rtf.format(-Math.round(abs / 365 / 86400), "year");
}