fix: date formatting for Dropbox data imports

This commit is contained in:
Christian Vidal Wolf
2026-04-23 21:44:26 +02:00
parent 8ffcae5eef
commit b662acddd7
+10
View File
@@ -240,6 +240,16 @@ const articleNoIdx = resolvedCols.ARTICLE_NO;
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));