only attempting converting a date string if it looks like a date without year first w/ burnettk

This commit is contained in:
jasquat 2024-01-04 17:17:02 -05:00
parent 7489d17f4f
commit 4f5a590e1e
No known key found for this signature in database
1 changed files with 4 additions and 5 deletions

View File

@ -41,12 +41,11 @@ const convertDateObjectToFormattedString = (dateObject: Date) => {
}; };
const dateStringToYMDFormat = (dateString: string) => { const dateStringToYMDFormat = (dateString: string) => {
// if the date looks like it's already in yyyy-MM--dd format then just return it if (dateString && dateString.match(/^\d{2}-\d{2}-\d{4}$/)) {
if (dateString.match(/^\d{4}-\d{2}-\d{2}$/)) { const newDate = parse(dateString, DATE_FORMAT, new Date());
return dateString; return format(newDate, 'yyyy-MM-dd');
} }
const newDate = parse(dateString, DATE_FORMAT, new Date()); return dateString;
return format(newDate, 'yyyy-MM-dd');
}; };
const convertDateAndTimeStringsToDate = ( const convertDateAndTimeStringsToDate = (