add dateFormat helper

This commit is contained in:
Thomas Ruoff
2020-07-29 00:00:42 +02:00
parent 1935fbf8e9
commit a26e58b43e

View File

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