move rest into pages

This commit is contained in:
Thomas Ruoff
2020-08-01 16:05:58 +02:00
parent 528f46a533
commit 793b499c76
9 changed files with 32 additions and 8 deletions

25
pages/helpers/date.js Normal file
View File

@@ -0,0 +1,25 @@
import moment from 'moment'
export function getDays({ startDate, endDate }) {
let currentDay = moment(startDate)
const days = [dateFormat(currentDay)]
if (!endDate) {
return days
}
const end = moment(endDate)
while (currentDay < end) {
currentDay = currentDay.add(1, 'day')
days.push(dateFormat(currentDay))
}
return days
}
export function dateFormat(date) {
if (!date) {
return null
}
return moment(date).format('YYYY-MM-DD')
}