Judge the date is in same week as another date - Node.js Date

Node.js examples for Date:Week

Description

Judge the date is in same week as another date

Demo Code


/**/*from   w ww  .j  av a  2 s. c o m*/
 * Judge the date is in same week as another date
 * @param  {date}  date
 * @return {Boolean}
 */
Date.prototype.isSameWeek = function(date)
{
    var weekStart = this.getLastWeekday();
    var weekEnd = weekStart.clone().addDays(7);
    return date >= weekStart && date < weekEnd;
};

Related Tutorials