Get all days that are not equivalent to the provided day - Node.js Date

Node.js examples for Date:Day

Description

Get all days that are not equivalent to the provided day

Demo Code


/**/*from  w ww.j  av a2 s.  c o  m*/
 * @description Helper function to get all days that are not equivalent to the
 *   provided day.
 * @param {Date} day: Day to exclude.
 * @param {Array of Object} days: All days.
 * @returns {Array of Objects} All non-matching days.
*/
allOtherDays: function (day, days) {
  var others = [];
  for (var i = 0; i < days.length; ++i) {
    var ith = new Date(days[i].value.date);
    if (day.getMonth() !== ith.getMonth()
    ||  day.getDate() !== ith.getDate()) {
      others.push(days[i]);
    }
  }
  return others;
}

Related Tutorials