把周数转化为日期
Posted yang_chuanlong
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了把周数转化为日期相关的知识,希望对你有一定的参考价值。
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;
以上是关于把周数转化为日期的主要内容,如果未能解决你的问题,请参考以下文章