import moment from "moment-business-days";

// moment.updateLocale("ca", {
//   workingWeekdays: [1, 2, 3, 4, 5, 6],
// });

export const CalculateWorkingDaysThisMonth = () => {
  return moment().endOf("month").businessDaysIntoMonth();
};

export const CalculateWorkingDaysAsOfToday = () => {
  return moment().businessDaysIntoMonth();
};

export const WeeklyTargetHrs = (dailyTargetHrs, bodyshop) => {
  return dailyTargetHrs * 5;
};

export const MonthlyTargetHrs = (dailyTargetHrs, bodyshop) => {
  return dailyTargetHrs * CalculateWorkingDaysThisMonth();
};

export const AsOfTodayTargetHrs = (dailyTargetHrs, bodyshop) => {
  return dailyTargetHrs * CalculateWorkingDaysAsOfToday();
};

export const AsOfDateTargetHours = (dailyTargetHours, date) => {
  return (
    dailyTargetHours * moment().startOf("month").businessDiff(moment(date))
  );
};

export const ListOfBusinessDaysInCurrentMonth = () => {
  const momentListOfDays = moment().monthBusinessDays();

  return momentListOfDays.map((i) => i.format("YYYY-MM-DD"));
};

export const ListOfDaysInCurrentMonth = () => {
  const days = [];
  const dateStart = moment().startOf("month");
  const dateEnd = moment().endOf("month");
  while (dateEnd.diff(dateStart, "days") > 0) {
    days.push(dateStart.format("YYYY-MM-DD"));
    dateStart.add(1, "days");
  }
  days.push(dateEnd.format("YYYY-MM-DD"));
  return days;
};

export const ListDaysBetween = ({ start, end }) => {
  const days = [];
  const dateStart = moment(start);
  const dateEnd = moment(end);
  while (dateEnd.diff(dateStart, "days") > 0) {
    days.push(dateStart.format("YYYY-MM-DD"));
    dateStart.add(1, "days");
  }
  days.push(dateEnd.format("YYYY-MM-DD"));
  return days;
};
