Phase 0.3: migrate date formatting to date-fns
This commit is contained in:
@@ -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';
|
||||
|
||||
Reference in New Issue
Block a user