Use explicit dates with gaps and fix bugs that this uncovers

This commit is contained in:
Julia Friesel
2018-07-10 14:22:40 +02:00
parent 0de009335f
commit 81b7b46b23
3 changed files with 66 additions and 77 deletions
+6 -2
View File
@@ -1,5 +1,9 @@
import { LocalDate } from "js-joda"
export default function(cycle) {
const fiveDayRuleDays = cycle.slice(0, 5)
const startDate = LocalDate.parse(cycle[0].date)
const fiveDayEndDate = startDate.plusDays(4).toString()
const fiveDayRuleDays = cycle.slice(0, 5).filter(d => d.date <= fiveDayEndDate)
const preOvulatoryDays = getDaysUntilFertileMucus(fiveDayRuleDays)
return {
cycleDays: preOvulatoryDays,
@@ -7,7 +11,7 @@ export default function(cycle) {
date: preOvulatoryDays[0].date
},
end: {
date: preOvulatoryDays[preOvulatoryDays.length - 1].date,
date: fiveDayEndDate
}
}
}