获取当前月份所有周期
// 获取总月数
function getDay(date) {
// 获取的是上个月的必须+1
let d = new Date(date.getFullYear(), date.getMonth() + 1, 0)
return d.getDate()
}
// 判断每月月的第一周是从几号开始
function isHeadWeek(year, month) {
// 获取月头第一天的时间
var getHeadDate = new Date(year, parseInt(month), 1),
// 获取第一天是星期几
getHeadDates = getHeadDate.getDay();
let isReduceDay = 0;
// 如果为星期天直接归纳为上个月的周期
if (getHeadDates == 6 || getHeadDates == 0) {
if (getHeadDates == 6) {
isReduceDay = 2
} else {
isReduceDay = 1
}
}
getHeadDate = new Date(year, parseInt(month), 1 + isReduceDay);
console.log(getHeadDate);
// 返回每个月的第一周的开始时间
return getHeadDate
}
function isLastWeek(year, month) {
var d = new Date(year, parseInt(month) + 1, 0),
getLastDay = d.getDay(),
getCurrentMonthDay = d.getDate();
let isReduceDay = 0;
console.log(getLastDay);
if (getLastDay == 1 || getLastDay == 2 || getLastDay == 3 || ge