function weekOfYearDay(time) {
var time=time;
time = time.substring(0,4)+"-"+time.substring(4,6)+"-"+time.substring(6,8);
oToday = new Date(time);
currentDay = oToday.getDay();
if (currentDay == 0) { currentDay = 7 }
mondayTime = oToday.getTime() - (currentDay - 1) * 24 * 60 * 60 * 1000;
sundayTime = oToday.getTime() + (7 - currentDay) * 24 * 60 * 60 * 1000;
var monday = new Date(mondayTime).toLocaleDateString();
var month = monday.substring(5,7) >= 10 ? monday.substring(5,7) : "0" + monday.substring(5,7);
var day = monday.substring(8,10) >= 10 ? monday.substring(8,10)+"" : "0"+monday.substring(8,10);
monday = monday.substring(0,4)+month+day;
var sunday = new Date(sundayTime).toLocaleDateString();
var s_month = sunday.substring(5,7) >= 10 ? sunday.substring(5,7) : "0" + sunday.substring(5,7);
var s_day = sunday.substring(8,10) >= 10 ? sunday.substring(8,10)+"" : "0"+sunday.substring(8,10);
sunday = sunday.substring(0,4)+s_month+s_day;
sunday = s_month+s_day;
return monday + "~" + sunday;
}
//获取某年某周的开始日期
function getBeginDateOfWeek(paraYear, weekIndex){
var firstDay = GetFirstWeekBegDay(paraYear);
//7*24*3600000 是一星期的时间毫秒数,(JS中的日期精确到毫秒)
var time=(weekIndex-1)*7*24*3600000;
var beginDay = firstDay;
//为日期对象 date 重新设置成时间 time
beginDay.setTime(firstDay.valueOf()+time);
return formatDate(beginDay);
}
//获取某年某周的结束日期
function getEndDateOfWeek(paraYear, weekIndex){
var firstDay = GetFirstWeekBegDay(paraYear);
//7*24*3600000 是一星期的时间毫秒数,(JS中的日期精确到毫秒)
var time=(weekIndex-1)*7*24*3600000;
var weekTime = 6*24*3600000;
var endDay = firstDay;
//为日期对象 date 重新设置成时间 time
endDay.setTime(firstDay.valueOf()+weekTime+time);
return formatDate(endDay);
}