function getWeek(year, month, day) {
const date = new Date(year, month, day);
const nowWeek = date.getDay();
const nowEnd = new Date(year, month + 1, 0).getDate();
const nowStar = 1;
const preEnd = new Date(year, month, 0).getDate();
const returnWeek = []
for (let i = 1; i <= 7; i++) {
const pushDate = day + i - (nowWeek || 7);
if (pushDate < nowStar) {
returnWeek.push(preEnd + pushDate);
} else if (pushDate > nowEnd) {
returnWeek.push(pushDate - nowEnd);
} else {
returnWeek.push(pushDate);
}
}
return returnWeek;
}
获取当前日期的哪个礼拜的值
最新推荐文章于 2023-04-25 11:10:48 发布