only attempting converting a date string if it looks like a date without year first w/ burnettk
This commit is contained in:
parent
7489d17f4f
commit
4f5a590e1e
|
@ -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 = (
|
||||||
|
|
Loading…
Reference in New Issue