mirror of
https://github.com/binaricat/Netcatty.git
synced 2026-11-17 21:10:48 +00:00
- Change SFTP date format from ISO 8601 to readable YYYY-MM-DD HH:mm - Fix lastModifiedFormatted to use formatDate instead of raw ISO string - Hide "General" group at root level in vault (hosts already shown below) - Fix General group filter to match hosts with empty/undefined group - Exclude .github/** from ESLint (CI scripts don't need local linting) Co-Authored-By: Claude <noreply@anthropic.com>
17 lines
860 B
TypeScript
17 lines
860 B
TypeScript
export const formatBytes = (bytes: number | string): string => {
|
|
const numBytes = typeof bytes === "string" ? parseInt(bytes, 10) : bytes;
|
|
if (isNaN(numBytes) || numBytes === 0) return "0 B";
|
|
const units = ["B", "KB", "MB", "GB", "TB"];
|
|
const i = Math.floor(Math.log(numBytes) / Math.log(1024));
|
|
const size = numBytes / Math.pow(1024, i);
|
|
return `${size.toFixed(i === 0 ? 0 : 1)} ${units[i]}`;
|
|
};
|
|
|
|
export const formatDate = (dateStr: string | number | undefined): string => {
|
|
if (!dateStr) return "--";
|
|
const date = typeof dateStr === "number" ? new Date(dateStr) : new Date(dateStr);
|
|
if (isNaN(date.getTime())) return String(dateStr);
|
|
const pad = (value: number) => value.toString().padStart(2, "0");
|
|
return `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())} ${pad(date.getHours())}:${pad(date.getMinutes())}`;
|
|
};
|