Exemple #1
0
 noLeapYears.forEach(function(year) {
     var d = new Date(year, 0, 1);
     assert.isFalse(dates.isLeapYear(d), "No Leap Year " + year);
     assert.equal(dates.daysInYear(d), 365, "No Leap Year " + year);
     assert.equal(dates.daysInFebruary(d), 28, "No Leap Year " + year);
     assert.equal(dates.daysInMonth(new Date(year, 1, 1)), 28, "No Leap Year " + year);
     assert.isFalse(dates.checkDate(year, 1, 29), "No Leap Year " + year);
 });
Exemple #2
0
 leapYears.forEach(function(year) {
     var d = new Date(year, 1, 1);
     assert.isTrue(dates.isLeapYear(d), "Leap Year " + year);
     assert.equal(dates.daysInYear(d), 366, "Leap Year " + year);
     assert.equal(dates.daysInFebruary(d), 29, "Leap Year " + year);
     assert.equal(dates.daysInMonth(new Date(year, 1, 1)), 29, "Leap Year " + year);
     assert.isTrue(dates.checkDate(year, 1, 29), "Leap Year " + year);
 });
Exemple #3
0
exports.testDaysInMonth = function() {
    assert.equal(dates.daysInMonth(new Date(2010, 0, 1)), 31); // Jan
    assert.equal(dates.daysInMonth(new Date(2010, 1, 1)), 28); // Feb
    assert.equal(dates.daysInMonth(new Date(2010, 2, 1)), 31); // Mar
    assert.equal(dates.daysInMonth(new Date(2010, 3, 1)), 30); // Apr
    assert.equal(dates.daysInMonth(new Date(2010, 4, 1)), 31); // May
    assert.equal(dates.daysInMonth(new Date(2010, 5, 1)), 30); // Jun
    assert.equal(dates.daysInMonth(new Date(2010, 6, 1)), 31); // Jul
    assert.equal(dates.daysInMonth(new Date(2010, 7, 1)), 31); // Aug
    assert.equal(dates.daysInMonth(new Date(2010, 8, 1)), 30); // Sep
    assert.equal(dates.daysInMonth(new Date(2010, 9, 1)), 31); // Oct
    assert.equal(dates.daysInMonth(new Date(2010, 10, 1)), 30); // Nov
    assert.equal(dates.daysInMonth(new Date(2010, 11, 1)), 31); // Dec

    // Leap Year
    assert.equal(dates.daysInMonth(new Date(2008, 1, 1)), 29); // Feb
};