Get actual amount of cycle days to display

This commit is contained in:
Julia Friesel
2018-08-12 11:21:11 +02:00
parent 0afaf8e297
commit cd1e689aae
4 changed files with 27 additions and 12 deletions
+12 -2
View File
@@ -1,5 +1,5 @@
import Realm from 'realm'
import { LocalDate } from 'js-joda'
import { LocalDate, ChronoUnit } from 'js-joda'
import {
cycleWithTempAndNoMucusShift,
cycleWithFhm,
@@ -193,6 +193,15 @@ function getColumnNamesForCsv() {
}
}
function getAmountOfCycleDays() {
const amountOfCycleDays = cycleDaysSortedByDate.length
if (!amountOfCycleDays) return 0
const earliest = cycleDaysSortedByDate[amountOfCycleDays - 1]
const today = LocalDate.now()
const earliestAsLocalDate = LocalDate.parse(earliest.date)
return earliestAsLocalDate.until(today, ChronoUnit.DAYS)
}
export {
saveSymptom,
getOrCreateCycleDay,
@@ -203,5 +212,6 @@ export {
deleteAll,
getPreviousTemperature,
getCycleDay,
getColumnNamesForCsv
getColumnNamesForCsv,
getAmountOfCycleDays
}