//重组,查询区间内的日期都返回
var start = new Date(starttime);
var end = new Date(endtime);
while (start <= end) {
//记录集里查找该日期
if (!DateIsexists(queueList, start)) {
queueList.push({"date": start.format("yyyy-MM-dd"), "num": 0});
}
if (!DateIsexists(bookList, start)) {
bookList.push({"date": start.format("yyyy-MM-dd"), "num": 0});
}
//日期加一天
start = new Date(start.setDate(start.getDate() + 1));
}
//排序
function sortByKey(array, key) {
return array.sort(function(a, b) {
var x = a[key]; var y = b[key];
return ((x < y) ? -1 : ((x > y) ? 1 : 0));
});
}
//检查日期是否存在
function DateIsexists(list, d) {
var flag = false;
list.forEach(function (val) {
if (val.date == d.format("yyyy-MM-dd")) {
flag = true;
return false;
}
});
return flag;
}