let todayRange = () => {
  return [
    new Date(new Date().setHours(0, 0, 0)),
    new Date(new Date().valueOf() + 60 * 60 * 1000 * 24).setHours(0, 0, 0, -1)
  ]
};

let monthRange = () => {
  const start = new Date();
  const end = new Date();
  const days = 30;
  start.setTime(start.setHours(0, 0, 0, 0) - 1000 * 60 * 60 * 24 * days);
  end.setTime(new Date().setHours(23, 59, 59, 999));
  return [start, end]
};


let confirmOption = {
  center: true,
  type: "warning",
  dangerouslyUseHTMLString: true
};


let pickerOptionsQuickSelect = {
  shortcuts: [
    {
      text: "今天",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setHours(0, 0, 0, 0);
        end.setHours(23, 59, 59, 999);
        picker.$emit("pick", [start, end]);
      }
    },
    {
      text: "昨天",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.setHours(0, 0, 0, 0) - 1000 * 60 * 60 * 24);
        end.setTime(start.getTime() + 1000 * 60 * 60 * 24 - 1000);
        picker.$emit("pick", [start, end]);
      }
    },
    {
      text: "最近一周",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        const days = 7;
        start.setTime(start.setHours(0, 0, 0, 0) - 1000 * 60 * 60 * 24 * days);
        end.setTime(new Date().setHours(23, 59, 59, 999));
        picker.$emit("pick", [start, end]);
      }
    },
    {
      text: "最近一个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        const days = 30;
        start.setTime(start.setHours(0, 0, 0, 0) - 1000 * 60 * 60 * 24 * days);
        end.setTime(new Date().setHours(23, 59, 59, 999));
        picker.$emit("pick", [start, end]);
      }
    },
    {
      text: "最近三个月",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        const days = 90;
        start.setTime(start.setHours(0, 0, 0, 0) - 1000 * 60 * 60 * 24 * days);
        end.setTime(new Date().setHours(23, 59, 59, 999));
        picker.$emit("pick", [start, end]);
      }
    },
    {
      text: "一小时内",
      onClick(picker) {
        const end = new Date();
        const start = new Date();
        start.setTime(start.getTime() - 3600 * 1000);
        picker.$emit("pick", [start, end]);
      }
    }
  ]
};

export default {pickerOptionsQuickSelect, confirmOption, todayRange, monthRange}
