一个输入日期，结束日期，计算周数js的函数

function queryWeekbydate(start,end)
{
var o= {
startTime: null,
endTime: null,
weekCount: 0,
currentDate: function (w) {

var n = new Date(this.startTime);
n.setDate(n.getDate() + parseInt(w) * 7);
var d = this.formate(n);
return d;
},
//增加天数
var date = new Date(newstart);
date.setDate(date.getDate() + parseInt(days));
return this.formate(date);
},
//获取周数
getweekCount: function (e) {
var total = (e.getTime() - this.startTime.getTime()) / 1000;
var day = parseInt(total / (24 * 60 * 60));
var wc = parseInt(day / 7);
return wc;
},
//格式化
formate: function (s) {

var r = s.getFullYear() + "-" + (parseInt(s.getMonth()+1) < 10 ? ("0" + (s.getMonth()+1)) : (s.getMonth()+1)) + "-" + (parseInt(s.getDate()) < 10 ? ("0" + s.getDate()) : s.getDate());

return r;
}
}
var array = start.toString().split('-');
var array2 = end.toString().split('-');
o.startTime = new Date(array[0], Number(array[1]) - 1, Number(array[2]));
//星期几
var newS = o.startTime.getDay();
var day = newS - 1;
o.startTime.setDate(o.startTime.getDate() - day);
o.endTime = new Date(array2[0], Number(array2[1]) - 1, Number(array2[2]));
o.weekCount = function(end,o) {
var c = o.getweekCount(end);
return c;
}(o.endTime,o);
return o;

}