Node.js examples for Date:Date Calculation
Looping through dates by step
// from http://trentrichardson.com/2011/09/29/looping-through-dates-with-javascript/ Date.prototype.each = function (endDate, part, step, fn, bind) { var fromDate = new Date(this.getTime()), toDate = new Date(endDate.getTime()), pm = fromDate <= toDate ? 1 : -1, i = 0;/* ww w. ja v a 2 s . c om*/ while ((pm === 1 && fromDate <= toDate) || (pm === -1 && fromDate >= toDate)) { if (fn.call(bind, fromDate, i, this) === false) break; i += step; fromDate.adjust(part, step * pm); } return this; };