js 已知未来七天时间数组格式为 xxxx-xx-xx 和闭馆日期时间数组格式为 xxxx-xx-xx 获取未来7天开闭馆日期数组对象
可以使用以下代码获取未来7天的开闭馆日期数组对象:
const futureDates = ["xxxx-xx-xx", "xxxx-xx-xx", "xxxx-xx-xx", "xxxx-xx-xx", "xxxx-xx-xx", "xxxx-xx-xx", "xxxx-xx-xx"];
const closedDates = ["xxxx-xx-xx", "xxxx-xx-xx", "xxxx-xx-xx"];
const openingClosingDates = futureDates.map(date => {
const isOpen = !closedDates.includes(date);
return { date, isOpen };
});
console.log(openingClosingDates);
其中,futureDates是未来7天的时间数组,closedDates是闭馆日期时间数组。openingClosingDates是未来7天的开闭馆日期数组对象,每个对象包含日期和是否开馆的信息。
请将代码中的"xxxx-xx-xx"替换为实际的日期
原文地址: https://www.cveoy.top/t/topic/hCG9 著作权归作者所有。请勿转载和采集!