计算任意日期所在周起止日期
function showDate(date)
{
var now = date ? new Date(date) : new Date();
var start = date ? new Date(date) : new Date();
var end = date ? new Date(date) : new Date();
var n = now.getDay();
var result = {};
start.setDate(now.getDate() - n + 1);
end.setDate(now.getDate() - n + 7);
start = start.getFullYear() + "-" + toDouble(start.getMonth() + 1) + "-" + toDouble(start.getDate());
end = end.getFullYear() + "-" + toDouble(end.getMonth() + 1) + "-" + toDouble(end.getDate());
result.start = start;
result.end = end;
return result;
}
function toDate(date)
{
var aDate = date.split("-");
var result = new Date(aDate[0], (aDate[1] - 1), aDate[2]);
return result;
}
function toDouble(num)
{
return num < 10 ? '0' + num : num;
}