export const isDateValid = (date: Date | string | null) => {
  if (date === null) {
    return false;
  } else if (date instanceof Date) {
    return validDateObject(date);
  } else {
    return validDateString(date);
  }
};

export const validDateString = (dateString: string) => validDateObject(new Date(dateString));

const validDateObject = (dateObject: Date) => !isNaN(dateObject.getTime());
