feat: add end support for calc-schedule-budget

This commit is contained in:
2024-08-13 08:21:29 +02:00
parent 3636531a18
commit b7227b50f4

View File

@@ -41,16 +41,24 @@ for (const s of schedules) {
} }
const start = (typeof s._date === 'string' ? s._date : s._date.start).slice(0, 7); const start = (typeof s._date === 'string' ? s._date : s._date.start).slice(0, 7);
// TODO: get end
if (start > month) { if (start > month) {
console.log(chalk.grey(`- ${formatSchedule(s)}: not in range`)); console.log(chalk.grey(`- ${formatSchedule(s)}: not in range`));
continue; continue;
} }
let date = start; if (s.name === "Etails - Téléphone" || s.name === "FF14") {
while (date < month) { console.log(s);
date = addFromFrequency(date, s._date.frequency, s._date.interval);
} }
let date = start;
if (typeof s._date === 'object') {
let occurrences = 0;
while (date < month || occurrences < s._date.endOccurrences) {
occurrences += 1;
date = addFromFrequency(date, s._date.frequency, s._date.interval);
}
}
if (date !== month) { if (date !== month) {
console.log(chalk.grey(`- ${formatSchedule(s)}: not the specified month`)); console.log(chalk.grey(`- ${formatSchedule(s)}: not the specified month`));
continue; continue;