mirror of
https://github.com/tomru/pfadi-bussle.git
synced 2026-03-04 23:17:12 +01:00
add dateFormat helper
This commit is contained in:
@@ -2,7 +2,7 @@ import moment from 'moment'
|
|||||||
|
|
||||||
export function getDays({ startDate, endDate }) {
|
export function getDays({ startDate, endDate }) {
|
||||||
let currentDay = moment(startDate)
|
let currentDay = moment(startDate)
|
||||||
const days = [currentDay.format('YYYY-MM-DD')]
|
const days = [dateFormat(currentDay)]
|
||||||
|
|
||||||
if (!endDate) {
|
if (!endDate) {
|
||||||
return days
|
return days
|
||||||
@@ -11,8 +11,15 @@ export function getDays({ startDate, endDate }) {
|
|||||||
const end = moment(endDate)
|
const end = moment(endDate)
|
||||||
while (currentDay < end) {
|
while (currentDay < end) {
|
||||||
currentDay = currentDay.add(1, 'day')
|
currentDay = currentDay.add(1, 'day')
|
||||||
days.push(currentDay.format('YYYY-MM-DD'))
|
days.push(dateFormat(currentDay))
|
||||||
}
|
}
|
||||||
|
|
||||||
return days
|
return days
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export function dateFormat(date) {
|
||||||
|
if (!date) {
|
||||||
|
return null
|
||||||
|
}
|
||||||
|
return moment(date).format('YYYY-MM-DD')
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user