From 4f5a590e1e0acb58ca788c8fe73e49a349d0d1eb Mon Sep 17 00:00:00 2001 From: jasquat Date: Thu, 4 Jan 2024 17:17:02 -0500 Subject: [PATCH] only attempting converting a date string if it looks like a date without year first w/ burnettk --- .../src/services/DateAndTimeService.tsx | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/spiffworkflow-frontend/src/services/DateAndTimeService.tsx b/spiffworkflow-frontend/src/services/DateAndTimeService.tsx index 8599183f9..0b57f6d6d 100644 --- a/spiffworkflow-frontend/src/services/DateAndTimeService.tsx +++ b/spiffworkflow-frontend/src/services/DateAndTimeService.tsx @@ -41,12 +41,11 @@ const convertDateObjectToFormattedString = (dateObject: Date) => { }; const dateStringToYMDFormat = (dateString: string) => { - // if the date looks like it's already in yyyy-MM--dd format then just return it - if (dateString.match(/^\d{4}-\d{2}-\d{2}$/)) { - return dateString; + if (dateString && dateString.match(/^\d{2}-\d{2}-\d{4}$/)) { + const newDate = parse(dateString, DATE_FORMAT, new Date()); + return format(newDate, 'yyyy-MM-dd'); } - const newDate = parse(dateString, DATE_FORMAT, new Date()); - return format(newDate, 'yyyy-MM-dd'); + return dateString; }; const convertDateAndTimeStringsToDate = (