diff --git a/calc-schedule-budget.js b/calc-schedule-budget.js index 94cb8d6..b8ec675 100644 --- a/calc-schedule-budget.js +++ b/calc-schedule-budget.js @@ -41,16 +41,24 @@ for (const s of schedules) { } const start = (typeof s._date === 'string' ? s._date : s._date.start).slice(0, 7); - // TODO: get end if (start > month) { console.log(chalk.grey(`- ${formatSchedule(s)}: not in range`)); continue; } - let date = start; - while (date < month) { - date = addFromFrequency(date, s._date.frequency, s._date.interval); + if (s.name === "Etails - Téléphone" || s.name === "FF14") { + console.log(s); } + + 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) { console.log(chalk.grey(`- ${formatSchedule(s)}: not the specified month`)); continue;