changs output of getpredictedmenses, adds days to calendar
This commit is contained in:
+12
-8
@@ -163,12 +163,11 @@ export default function config(opts) {
|
||||
|
||||
function getPredictedMenses() {
|
||||
const allMensesStarts = getAllMensesStarts()
|
||||
|
||||
const atLeastOneCycle = allMensesStarts.length > 1
|
||||
if (!atLeastOneCycle ||
|
||||
allMensesStarts.length < minCyclesForPrediction
|
||||
) {
|
||||
return {}
|
||||
return []
|
||||
}
|
||||
const cycleLengths = getCycleLength(allMensesStarts)
|
||||
const cycleInfo = getCycleLengthStats(cycleLengths)
|
||||
@@ -181,15 +180,20 @@ export default function config(opts) {
|
||||
} else {
|
||||
periodStartVariation = 2
|
||||
}
|
||||
var lastStart = allMensesStarts[0]
|
||||
if (periodDistance - 5 < periodStartVariation) { // otherwise predictions overlap
|
||||
return []
|
||||
}
|
||||
let lastStart = LocalDate.parse(allMensesStarts[0])
|
||||
const predictedMenses = []
|
||||
for (let i = 0; i < 3; i++) {
|
||||
lastStart = LocalDate.parse(lastStart).plusDays(periodDistance).toString()
|
||||
const nextPredictedRange = {
|
||||
'startDate': LocalDate.parse(lastStart).minusDays(periodStartVariation).toString(),
|
||||
'endDate': LocalDate.parse(lastStart).plusDays(periodStartVariation).toString()
|
||||
lastStart = lastStart.plusDays(periodDistance)
|
||||
const nextPredictedDates = [lastStart.toString()]
|
||||
for (let j = 0; j < periodStartVariation; j++) {
|
||||
nextPredictedDates.push(lastStart.minusDays(j+1).toString())
|
||||
nextPredictedDates.push(lastStart.plusDays(j+1).toString())
|
||||
}
|
||||
predictedMenses.push(nextPredictedRange)
|
||||
nextPredictedDates.sort()
|
||||
predictedMenses.push(nextPredictedDates)
|
||||
}
|
||||
return predictedMenses
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user