function convertWeekNumberToFirstDate(sYear, sWeek, startFromFirstMonday) { if (startFromFirstMonday == undefined) startFromFirstMonday = true; var weekIndex = 1; var year = parseInt(sYear); var week = parseInt(sWeek); var i = 1; var dFirstDate = new Date(year, 0, i); if (!startFromFirstMonday) { if (weekIndex < week) { weekIndex++; } else return dFirstDate; } if (dFirstDate.getDay() != 1) { i += 7 - dFirstDate.getDay() + 1; dFirstDate.setFullYear(year, 0, i); } if (weekIndex < week) { i += 7*(week-weekIndex); dFirstDate.setFullYear(year, 0, i); } return dFirstDate; }
把周数转化为日期
最新推荐文章于 2022-10-20 17:30:15 发布