type nullableDate = Date | string;

export const convertToDate = (checkDate: nullableDate) => {
	return checkDate === "" ? null : `\'${checkDate.substr(0, 10)}\'`;
};

export function mysqlDateFormat(inDate) {
	let ret = "";

	if (typeof inDate !== "undefined" && typeof inDate !== "object" && inDate !== null && inDate !== "") {
		ret = inDate.substr(5, 2) + "-" + inDate.substr(8, 2) + "-" + inDate.substr(0, 4);
	} else if (inDate !== null && typeof inDate === "object") {
		ret =
			inDate.getFullYear() +
			"-" +
			(inDate.getMonth() + 1).toString().padStart(2, 0) +
			"-" +
			inDate.getDate().toString().padStart(2, 0);
	}

	return ret;
}
