diff --git a/src/App.tsx b/src/App.tsx index e073bfc..2fb0cb1 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -162,6 +162,16 @@ export default function App() { } } + // Handle date columns - Excel serial dates are numbers >= 25569 (Jan 1, 1970) + if (header.includes('date') || header.includes('launch') || header.includes('ready')) { + if (typeof val === 'number' && val >= 25569 && val <= 60000) { + const excelEpoch = new Date(1899, 11, 30); + const date = new Date(excelEpoch.getTime() + val * 86400000); + return date.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' }); + } + return val; + } + const formatKeywords = ['price', 'eur', 'cost', 'msrp', 'net', 'gross', 'netto', 'brutto', 'pp', 'pph', 'uvp', 'vpe', 'stk', 'nw', 'gw', 'weight', 'kg']; const shouldFormat = formatKeywords.some(kw => header.includes(kw)); diff --git a/src/components/MatrixView.tsx b/src/components/MatrixView.tsx index 86e5ed3..ebca7c4 100644 --- a/src/components/MatrixView.tsx +++ b/src/components/MatrixView.tsx @@ -21,6 +21,16 @@ export function MatrixView({ data, headers }: MatrixViewProps) { // Convert header to lowercase for checks const h = header.toLowerCase(); + // Handle date columns - Excel serial dates are numbers >= 25569 (Jan 1, 1970) + if (h.includes('date') || h.includes('launch') || h.includes('ready')) { + if (typeof val === 'number' && val >= 25569 && val <= 60000) { + const excelEpoch = new Date(1899, 11, 30); + const date = new Date(excelEpoch.getTime() + val * 86400000); + return date.toLocaleDateString('en-GB', { day: '2-digit', month: '2-digit', year: 'numeric' }); + } + return val; + } + // Always format weight/NW/GW/kg columns to 2 decimals — checked before any exclusion logic if (h.includes('nw') || h.includes('gw') || h.includes('weight') || h.includes('kg')) { if (typeof val === 'number') return val.toFixed(2);