Node.js examples for Date:Day
Returns an array of day objects which occur before the specified date
/**//from w ww . j a v a 2 s . com * Date.getDaysBeforeDate() * returns an array of day objects which occur before the specified date * * @date * the date object from which you need to retrieve the previous days of the month */ Date.prototype.getDaysBeforeDate = function() { //declare vars var i; var iterdate = this; var array = [] var n = 0; var oneDay = 1000 * 60 * 60 * 24; //create the day objects and add them to the matrix as we go //we can determine this by looping through and subtracting a day away from the current day until the day is less than 1 for(i = this.getDate(); i > 1; i--) { //starting at the current day, count down until i is no longer > 0 //calculate the day's timestamp iterdate = new Date(iterdate.getTime() - oneDay); //get a new object from the iterdate - one day array[n] = iterdate; n++; //iterate n } //reverse the array since we counted backwards (up front, up back, up side ... upside yo head) return array.reverse(); };