1 回答
TA贡献1831条经验 获得超4个赞
你可以这样做:
var meetings = [
{
id: '1',
start_time: "2020-11-15T08:30:00+00:00",
end_time: "2020-11-15T14:15:00+00:00"
},
{
id: '2',
start_time: "2020-11-15T19:30:00+00:00",
end_time: "2020-11-15T20:30:00+00:00"
},
{
id: '3',
start_time: "2020-11-15T20:50:00+00:00",
end_time: "2020-11-15T21:30:00+00:00"
},
{
id: '4',
start_time: "2020-11-15T22:30:00+00:00",
end_time: "2020-11-15T22:40:00+00:00"
},
];
var startTime = '2020-11-15T00:00:00+00:00';
var endTime = '2020-11-15T23:59:00+00:00';
let availableHours = [];
for(let index in meetings){
if(index != meetings.length - 1){
index == 0 ? availableHours.push({start_time: startTime, end_time: meetings[index]['start_time'] }) : 0;
availableHours.push({start_time: meetings[index].end_time, end_time: meetings[+index + 1]['start_time'] });
} else {
availableHours.push({start_time: meetings[index].end_time, end_time: endTime })
}
}
console.log(meetings)
console.log(availableHours)
添加回答
举报