Набросал на коленке, есть что улучшить.
/**
* @param {Date} start
* @param {Date} finish
* @param {int} activityDurationInSeconds
* @param {int} [breakInSeconds]
* @return {array}
*/
function makeSchedule(start, finish, activityDurationInSeconds, breakInSeconds = 0) {
[start, finish] = [start, finish].map(val => +val).sort((a, b) => a - b);
const formatter = dateTime => {
return [
dateTime.getHours(),
dateTime.getMinutes(),
].map(val => val > 9 ? val : '0' + val).join(':');
}
const result = [];
const setDate = (date => milliseconds => {
date.setTime(milliseconds);
return date;
})(new Date());
let time = start;
while (time < finish) {
result.push([
formatter( setDate(time) ),
formatter( setDate(time += activityDurationInSeconds * 1000) )
]);
time += breakInSeconds * 1000;
}
return result;
}
console.table(
makeSchedule(
new Date().setHours(08, 00),
new Date().setHours(16, 00),
15 * 60, // convert minutes to seconds
0
)
);