mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 11:55:23 +02:00
fix: date formatting for Dropbox data imports
This commit is contained in:
+10
@@ -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));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user