import dayjs from "dayjs";
import { ElMessage } from "element-plus";

interface Options {
  len: number;
  end?: string;
  start?: string;
  name?: string;
}

export function isBeyondTime({ len, start, end, name }: Options) {
  let beyondTime = true;
  if (!start || !end) {
    ElMessage.warning("请选择" + name + "的时间区间!");
    return beyondTime;
  }

  beyondTime = dayjs(end).diff(start, "days") > len;
  if (beyondTime) {
    ElMessage.warning(name + "的时间区间不能超过 " + len + " 天");
  }

  return beyondTime;
}
