Compares two calendar events and determines their relationship - Node.js Date

Node.js examples for Date:Compare

Description

Compares two calendar events and determines their relationship

Demo Code


/**/*from w  w  w .j a va2  s .c om*/
 * @description Compares two calendar events and determines their
 *   relationship. Intended for sorting functions.
 * @param {Object} a: First date.
 * @param {Object} b: Second date.
 * @returns {Number}
*/
dateSort: function (a, b) {
  a = new Date(a.value.date);
  b = new Date(b.value.date);
  if (a.getTime() > b.getTime()) {
    return 1;
  }
  else {
    return -1;
  }
}

Related Tutorials