mirror of
https://github.com/christianvidalwolf-prog/Craze-Data-check.git
synced 2026-08-03 12:55:23 +02:00
Fix date columns showing numbers instead of dates
This commit is contained in:
+10
@@ -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));
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user