Phase 0.3: migrate date formatting to date-fns

This commit is contained in:
Agent Zero
2026-07-23 05:05:08 +02:00
parent 241850fddd
commit 57d18c1381
20 changed files with 133 additions and 56 deletions
+3 -6
View File
@@ -38,6 +38,8 @@ export function formatFileSize(bytes: number): string {
if (bytes < 1024 * 1024 * 1024) return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
return `${(bytes / (1024 * 1024 * 1024)).toFixed(1)} GB`;
}
import { formatDateShort } from '@/utils/date';
function getFileSize(file: DmsFile): number {
return file.size_bytes ?? file.size ?? 0;
@@ -45,12 +47,7 @@ function getFileSize(file: DmsFile): number {
function formatDate(dateStr: string | null | undefined): string {
if (!dateStr) return '';
try {
const d = new Date(dateStr);
return d.toLocaleDateString(undefined, { year: 'numeric', month: 'short', day: 'numeric' });
} catch {
return dateStr;
}
return formatDateShort(dateStr) || '';
}
export type ViewMode = 'list' | 'table' | 'icons-sm' | 'icons-md' | 'icons-lg';