/**2 * 判断年份是否为润年3 *4 * @param {Number} year5 */6 function isLeapYear(year) {7 return (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);8 }9 /**10 * 获取某一年份的某一月份的天数11 *12 * @param {Number} year13 * @param {Number} month14 */15 function getMonthDays(year, month) {16 return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][month] || (isLeapYear(year) ? 29 : 28);17 }26 /**27 * 获取某年的某天是第几周28 * @param {Number} y29 * @param {Number} m30 * @param {Number} d31 * @returns {Number}32 */33 function getWeekNumber(y, m, d) {34 var now = new Date(y, m - 1, d),35 year = now.getFullYear(),36 month = now.getMonth(),37 days = now.getDate();38 //那一天是那一年中的第多少天39 for (var i = 0; i < month; i++) {40 days += getMonthDays(year, i);41 }42 43 //那一年第一天是星期几44 var yearFirstDay = new Date(year, 0, 1).getDay() || 7;45 46 var week = null;47 if (yearFirstDay == 1) {48 week = Math.ceil(days / yearFirstDay);49 } else {50 days -= (7 - yearFirstDay + 1);51 week = Math.ceil(days / 7) + 1;52 }53 54 return week;55 }
转载于:https://www.cnblogs.com/SZ2015/p/4629817.html
相关资源:DirectX修复工具V4.0增强版