functionweekCalculator(beginDate, endDate){//跳过第一周,直接获取第二周周一时间const beginTime = beginDate.getTime()+(7-getLocalDay(beginDate))*(1000*60*60*24);//计算到结束时间的天数let day =(endDate.getTime()- beginTime)/(1000*60*60*24)+1;//计算周数,向上取整,加上之前跳过的一周return Math.ceil(day /7)+1;}//以周一为第一天,获取给定日期是本周第几天,若想以周天为第一天直接使用getDay()代替functiongetLocalDay(date){let day = date.getDay();return day ===0?6: day -1;}