// let timeopen = ["10", "00", "00"];
// let timeclose = ["19", "30", "00"];

// let timeInTable = [];

// while (timeopen[0] !== timeclose[0] && timeopen[1] !== timeopen[1]) {
//   let tmpTimeHourOpen = parseInt(timeopen[0]);
//   let tmpTimeMinuteOpen = parseInt(timeopen[1]);

//   let tableTimeHour = tmpTimeHourOpen;
//   let tableTimeMinute = tmpTimeMinuteOpen;

//   if (tmpTimeMinuteOpen === 45) {
//     tableTimeHour = tableTimeHour + 1;
//     tableTimeHour = 0
//   }else{

//   }

//   let timeTable = Number(timeopen[0]);
//   let timeTable = Number(timeopen[0]);

//   timeInTable.push();
// }

// console.log("test");

// ================================ 2 ===========================
// function addMinutes(date, minutes) {
//   return new Date(date.getTime() + minutes * 60000);
// }

// let date = new Date();
// let result = "";
// for (let index = 0; index < 30; index++) {
//   let m = ((((date.getMinutes() + 7.5) / 15) | 0) * 15) % 60;
//   let h = (((date.getMinutes() / 105 + 0.5) | 0) + date.getHours()) % 24;
//   date = new Date(date.getYear(), date.getMonth(), date.getDay(), h, m, 0, 0);

//   if (index > 0) result += ", ";
//   result += ("0" + h).slice(-2) + ":" + ("0" + m).slice(-2);
//   date = addMinutes(date, 15);
// }
// console.log('result', result)

// import moment from 'moment'

const moment = require("moment");

function calculate(endTime) {
  let timeStops = [];

  let timeopen = ["10", "00", "00"];

  let dateOpen = new Date();
  dateOpen.setHours(parseInt(timeopen[0]));
  dateOpen.setMinutes(parseInt(timeopen[1]));

  console.log("dateOpen", dateOpen);

  let startTime = moment(dateOpen).add(
    "m",
    15 - (moment(dateOpen).minute() % 15)
  );

  while (startTime < endTime) {
    timeStops.push(new moment(startTime));
    startTime.add("m", 15);
  }

  return timeStops;
}

let timeclose = ["19", "30", "00"];

let dateClose = new Date();
dateClose.setHours(parseInt(timeclose[0]));
dateClose.setMinutes(parseInt(timeclose[1]));

console.log("dateClose", dateClose);

// const result = calculate(moment().add("h", 1));
const result = calculate(moment(dateClose));
console.log("result : ", result.length);
