From b662acddd74f5b46a39af4e55d402d911af831c2 Mon Sep 17 00:00:00 2001 From: Christian Vidal Wolf Date: Thu, 23 Apr 2026 21:44:26 +0200 Subject: [PATCH] fix: date formatting for Dropbox data imports --- src/App.tsx | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/App.tsx b/src/App.tsx index c34410b..e3567cc 100644 --- a/src/App.tsx +++ b/src/App.tsx @@ -239,7 +239,17 @@ const articleNoIdx = resolvedCols.ARTICLE_NO; !(header.includes('nw') || header.includes('gw') || header.includes('weight') || header.includes('kg'))) { return val; } - + + // 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.toISOString().split('T')[0]; // Returns YYYY-MM-DD + } + 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));