// Date, Date -> Number
// Get the number of days between two dates
test("Date Diff In Days", 5, function(){
ok(DateDiffInDays(new Date("January 1, 2000"), new Date("January 1, 2000")) == 0, "Ok");
ok(DateDiffInDays(new Date("January 1, 2000"), new Date("January 2, 2000")) == 1, "Ok");
ok(DateDiffInDays(new Date("January 1, 2000"), new Date("January 11, 2000")) == 10, "Ok");
ok(DateDiffInDays(new Date("January 11, 2000"), new Date("January 1, 2000")) == -10, "Ok");
ok(DateDiffInDays(new Date("January 1, 2000"), new Date("April 10, 2000")) == 100, "Ok");
});
function DateDiffInDays(a, b)
{
var _MS_PER_DAY = 1000 * 60 * 60 * 24;
// Discard the time and time-zone information.
var utc1 = Date.UTC(a.getFullYear(), a.getMonth(), a.getDate());
var utc2 = Date.UTC(b.getFullYear(), b.getMonth(), b.getDate());
return Math.floor((utc2 - utc1) / _MS_PER_DAY);
}