From 087f7b9fa5eb8f1704081f5c6de7a8600b02fd54 Mon Sep 17 00:00:00 2001 From: Eric Gullickson <16152721+ericgullickson@users.noreply.github.com> Date: Mon, 23 Mar 2026 20:56:34 -0500 Subject: [PATCH] fix: replace toISOString date conversion in OCR parser with local time formatting (refs #237) The parseServiceDate function used toISOString().split('T')[0] which converts to UTC, shifting dates by one day depending on timezone. Standard parsing now uses getFullYear/getMonth/getDate (local time). MM/DD/YYYY parsing now formats directly from regex groups without round-tripping through a Date object. Co-Authored-By: Claude Opus 4.6 (1M context) --- .../maintenance/hooks/useMaintenanceReceiptOcr.ts | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/frontend/src/features/maintenance/hooks/useMaintenanceReceiptOcr.ts b/frontend/src/features/maintenance/hooks/useMaintenanceReceiptOcr.ts index 03a6a10..54790e9 100644 --- a/frontend/src/features/maintenance/hooks/useMaintenanceReceiptOcr.ts +++ b/frontend/src/features/maintenance/hooks/useMaintenanceReceiptOcr.ts @@ -107,17 +107,17 @@ function parseServiceDate(value: string | number | null): string | undefined { // Try standard parsing const date = new Date(dateStr); if (!isNaN(date.getTime())) { - return date.toISOString().split('T')[0]; + const y = date.getFullYear(); + const m = String(date.getMonth() + 1).padStart(2, '0'); + const d = String(date.getDate()).padStart(2, '0'); + return `${y}-${m}-${d}`; } // Try MM/DD/YYYY format const mdyMatch = dateStr.match(/(\d{1,2})\/(\d{1,2})\/(\d{4})/); if (mdyMatch) { const [, month, day, year] = mdyMatch; - const parsed = new Date(parseInt(year), parseInt(month) - 1, parseInt(day)); - if (!isNaN(parsed.getTime())) { - return parsed.toISOString().split('T')[0]; - } + return `${year}-${month.padStart(2, '0')}-${day.padStart(2, '0')}`; } return undefined;