lib/base/date/index.js
function (/*Date*/date1, /*Date*/date2, /*String*/portion) {
        date1 = new Date(date1);
        date2 = new Date((date2 || new Date()));

        if (portion === "date") {
            // Ignore times and compare dates.
            date1.setHours(0, 0, 0, 0);
            date2.setHours(0, 0, 0, 0);
        } else if (portion === "time") {
            // Ignore dates and compare times.
            date1.setFullYear(0, 0, 0);
            date2.setFullYear(0, 0, 0);
        }
        return date1 > date2 ? 1 : date1 < date2 ? -1 : 0;
    }
function (/*Date*/date1, /*Date*/date2, /*String*/portion) {
        date1 = new Date(date1);
        date2 = new Date((date2 || new Date()));

        if (portion === "date") {
            // Ignore times and compare dates.
            date1.setHours(0, 0, 0, 0);
            date2.setHours(0, 0, 0, 0);
        } else if (portion === "time") {
            // Ignore dates and compare times.
            date1.setFullYear(0, 0, 0);
            date2.setFullYear(0, 0, 0);
        }
        return date1 > date2 ? 1 : date1 < date2 ? -1 : 0;
    }
function ( /*Date*/ date1 , /*Date*/ date2 , /*String*/ portion ) { date1 = new Date ( date1 ) ; date2 = new Date ( ( date2 || new Date ( ) ) ) ; if ( portion === "date" ) { // Ignore times and compare dates. date1 . setHours ( 0 , 0 , 0 , 0 ) ; date2 . setHours ( 0 , 0 , 0 , 0 ) ; } else if ( portion === "time" ) { // Ignore dates and compare times. date1 . setFullYear ( 0 , 0 , 0 ) ; date2 . setFullYear ( 0 , 0 , 0 ) ; } return date1 > date2 ? 1 : date1 < date2 ? - 1 : 0 ; }
Compares two dates

@example

var d1 = new Date();
d1.setHours(0);
comb.date.compare(d1, d1); // 0

var d1 = new Date();
d1.setHours(0);
var d2 = new Date();
d2.setFullYear(2005);
d2.setHours(12);
comb.date.compare(d1, d2, "date"); // 1
comb.date.compare(d1, d2, "datetime"); // 1

var d1 = new Date();
d1.setHours(0);
var d2 = new Date();
d2.setFullYear(2005);
d2.setHours(12);
comb.date.compare(d2, d1, "date"); // -1
comb.date.compare(d1, d2, "time"); //-1

@param {Date|String} date1 the date to comapare
@param {Date|String} [date2=new Date()] the date to compare date1 againse
@param {"date"|"time"|"datetime"} portion compares the portion specified

@returns -1 if date1 is < date2 0 if date1 === date2  1 if date1 > date2
Compares two dates