I have the following function, which receives the date string and then checks if it is v alid moment date and then converts it to a JavaScript Date object.
const dateFromString = (value, locale) => {
  if (typeof value === 'string') {
    const dateMoment = moment(value, ['L LTS'], locale);
    return dateMoment.isValid() ? dateMoment.toDate() : null;
  }
  return value;
};
I also have a function which converts the Moment Date to String,
const dateToString = (value, locale) => {
  const dateMoment = moment(value);
  return dateMoment.isValid() ? dateMoment.format(currentDateFormat(locale, true)) : '';
};
Now, I need a function that can convert moment date to javascript date considering the locale, is there a way to do it?
