﻿String.prototype.trim = function() {
    return this.replace(/^\s*/, "").replace(/\s*$/, "");
};

Date.prototype.compareTo = function(otherDate) {
    if (typeof (otherDate) == "string") {
        otherDate = new Date(otherDate);
    }
    if (typeof (otherDate.getDate) != "function") {
        return -1;
    }
    if (this.getFullYear() > otherDate.getFullYear()) {
        return 1;
    } else if (this.getFullYear() < otherDate.getFullYear()) {
        return -1;
    }
    if (this.getMonth() > otherDate.getMonth()) {
        return 1;
    } else if (this.getMonth() < otherDate.getMonth()) {
        return -1;
    }
    if (this.getDate() > otherDate.getDate()) {
        return 1;
    } else if (this.getDate() < otherDate.getDate()) {
        return -1;
    }
    return 0;
}