x
天的时间,我试图遍历一系列约会(这些对象包含startDate
和endDate
),并发现x天中没有安排约会的最快发生时间[[C0 ])。尝试使用时刻,但我不确定这是否是正确(或最优雅)的路线。注意:我不仅要解决所有约会之后的第一个开放日,因为现有约会之间可能会有开放日]pendingStartDate
给定x天,我试图遍历一系列约会(包含startDate和endDate的对象),并找到x天中没有约会的最快发生时间...
import Moment from 'moment';
import { extendMoment } from 'moment-range';
const moment = extendMoment(Moment);
const determineStartDate = (daysNeeded, existingAppts) => {
// this is about as far as I've gotten...
pendingStartDate = moment();
existingAppts.forEach((a) => {
range = moment.range(moment(a.startDate), moment(a.endDate);
console.log(range.contains(pendingStartDate));
})
}
// just some dummy code to help explain
const daysNeeded = 2
const existingAppts = [
{ startDate: '2020-06-15', endDate: '2020-06-17' },
{ startDate: '2020-06-14', endDate: '2020-06-14' },
]
const pendingStartDate = determineStartDate(daysNeeded, existingAppts);