Files
MajoorWaldi-ComfyUI-Majoor-…/js/components/sidebar/utils/format.js
T
2026-01-08 02:21:14 +01:00

19 lines
638 B
JavaScript

export function formatFileSize(bytes) {
if (!bytes) return "Unknown";
const kb = bytes / 1024;
if (kb < 1024) return `${kb.toFixed(1)} KB`;
const mb = kb / 1024;
if (mb < 1024) return `${mb.toFixed(1)} MB`;
const gb = mb / 1024;
return `${gb.toFixed(2)} GB`;
}
export function formatShortDate(timestamp) {
if (!timestamp) return "";
const d = new Date(Number(timestamp) * 1000);
if (Number.isNaN(d.getTime())) return "";
const pad = (n) => String(n).padStart(2, "0");
return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
}