我遇到了一个问题,想知道是否有人能给我一些关于原因的见解。以下代码正在为日期添加一周:
while (c.getStamp() < b.getStamp()) {
var f = this.getWeek(c);
e.push(f);
c = (c.getStamp() + 604800).toDate();
}
...
Date.prototype.getStamp = function() {
return Math.round(this.getTime() / 1e3);
};
Number.prototype.toDate = function() {
return new Date(this * 1e3);
};
我试图让以下工作,但它会创建一个连续的循环:
while (c.getStamp() < b.getStamp()) {
var f = this.getWeek(c);
e.push(f);
c = new Date(c.getFullYear(), c.getMonth(), c.getDate + 7, 0, 0, 0);
}
地点c = JS Date, ie 05/01/12
和地点b = JS Date, ie 05/31/12