javascript 日期 获取周等

//判断某一日属于这一年的第几周
function weekofday(data) {
    var dt = new Date(data);
    var y = dt.getFullYear();
    var start = "1/1/" + y;
    start = new Date(start);
    starts = start.valueOf();
    startweek = start.getDay();
    dtweek = dt.getDay();
    var days = Math.round((dt.valueOf() - start.valueOf()) / (24 * 60 * 60 * 1000)) - (7 - startweek) - dt.getDay() - 1;
    days = Math.floor(days / 7);
    return (days + 3);
}
//获取当前周的周一和周末的日期
function showFEDateOfWeek(time) {
    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;
    //alert(weekofday(time));
   // alert("今天是" + oToday.getDate() + "号,星期" + currentDay + "\r");
    //alert("周一是" + new Date(mondayTime).getDate() + "号,周日是" + new Date(sundayTime).getDate() + "号");
    return new Date(mondayTime).formatDate("yyyy-MM-dd") + ";" + new Date(sundayTime).formatDate("yyyy-MM-dd");
  }orm