moves getCycleLength to corresponding files, adds function to get next menses (not finished) with first tests

This commit is contained in:
tina
2018-08-22 18:21:57 +02:00
parent b80c91cb46
commit ea21fc92a2
5 changed files with 171 additions and 15 deletions
+2 -12
View File
@@ -4,10 +4,10 @@ import {
View,
ScrollView
} from 'react-native'
import { LocalDate, ChronoUnit } from 'js-joda'
import styles from '../styles/index'
import cycleModule from '../lib/cycle'
import getCycleInfo from '../lib/cycle-length'
import {getCycleLengthStats as getCycleInfo, getCycleLength} from '../lib/cycle-length'
import {stats as labels} from './labels'
export default class Stats extends Component {
@@ -56,14 +56,4 @@ export default class Stats extends Component {
</ScrollView>
)
}
}
function getCycleLength(cycleStartDates) {
const cycleLengths = []
for (let i = 0; i < cycleStartDates.length - 1; i++) {
const nextCycleStart = LocalDate.parse(cycleStartDates[i])
const cycleStart = LocalDate.parse(cycleStartDates[i + 1])
cycleLengths.push(cycleStart.until(nextCycleStart, ChronoUnit.DAYS))
}
return cycleLengths
}