import { getValueByKeys } from "../../utils/index.js";
import { isUndefined } from "@pisell/utils";
import dayjs from "dayjs";
//#region src/components/table/Table/fields/date/filterUtil/index.ts
/**
* 判断filters和dataSource日期是否为同一天
* @param value 日期字符串或Dayjs对象
* @param key 键名
* @param item 对象
* @returns 若两个日期为同一天则返回true，否则返回false
*/
function filterUtil_default({ value, key, item }) {
	if (!value) return true;
	const valueDayjsObj = dayjs(value);
	if (!valueDayjsObj.isValid()) return true;
	const dataValue = getValueByKeys(item, key);
	if (isUndefined(dataValue)) return false;
	const dataDayjsObj = dayjs(dataValue);
	if (!dataDayjsObj.isValid()) return false;
	return dataDayjsObj.isSame(valueDayjsObj, "day");
}
//#endregion
export { filterUtil_default as default };
