Respect maxcyclelength in getCycleForStartDay

This commit is contained in:
Julia Friesel
2018-12-21 09:42:20 +01:00
parent d07ab446dc
commit 6b0d202272
2 changed files with 46 additions and 4 deletions
+5 -2
View File
@@ -65,17 +65,20 @@ export default function config(opts) {
}
function getCycleForCycleStartDay(startDay) {
// TODO this needs to be made cycle length aware. all other places can go?
const cycleStartIndex = cycleDaysSortedByDate.indexOf(startDay)
const i = cycleStartsSortedByDate.indexOf(startDay)
const nextMensesStart = cycleStartsSortedByDate[i - 1]
let cycle
if (nextMensesStart) {
return cycleDaysSortedByDate.slice(
cycle = cycleDaysSortedByDate.slice(
cycleDaysSortedByDate.indexOf(nextMensesStart) + 1,
cycleStartIndex + 1,
)
} else {
return cycleDaysSortedByDate.slice(0, cycleStartIndex + 1)
cycle = cycleDaysSortedByDate.slice(0, cycleStartIndex + 1)
}
return cycle.length > maxCycleLength ? null : cycle
}
function getCycleForDay(dayOrDate) {