// Quick test for date parsing from packing slip text export function testDateParsing() { // Sample text from actual packing slip const sampleText = ` Packing slip for order #3748364725 Order date 21 Jul, 2025 Ship to: David L `; // Test the regex pattern (same as in pdfParser.ts) const datePattern = /Order [Dd]ate:?\s*(\d{1,2} [A-Z][a-z]{2}, \d{4})/i; const dateMatch = sampleText.match(datePattern); console.log('=== TESTING DATE EXTRACTION ==='); console.log('Sample text contains:', sampleText.trim()); console.log('Date pattern:', datePattern.toString()); console.log('Match found:', dateMatch); if (dateMatch && dateMatch[1]) { const extractedDate = dateMatch[1]; console.log('Extracted date string:', extractedDate); // Test parsing to Date object try { const parsedDate = new Date(extractedDate); console.log('Parsed Date object:', parsedDate); console.log('Is valid date:', !isNaN(parsedDate.getTime())); console.log('ISO string:', parsedDate.toISOString()); // Test today's date for comparison const today = new Date(); console.log('Today for comparison:', today.toISOString()); console.log('Are dates different?', parsedDate.toDateString() !== today.toDateString()); return { success: true, extractedDate, parsedDate: parsedDate.toISOString(), isValidDate: !isNaN(parsedDate.getTime()), isDifferentFromToday: parsedDate.toDateString() !== today.toDateString() }; } catch (error) { console.error('Date parsing error:', error); return { success: false, error }; } } else { console.log('No date match found - this is the problem!'); return { success: false, error: 'No date match found' }; } } // Export for use in components export const dateTestResults = testDateParsing();