DateAssert.js revision 5d7303be23f52a46c5455a706a8e9862da8626b1
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * The DateAssert object provides functions to test JavaScript Date objects
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * for a variety of cases.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @class DateAssert
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @namespace
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * Asserts that a date's month, day, and year are equal to another date's.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @param {Date} expected The expected date.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @param {Date} actual The actual date to test.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @param {String} message (Optional) The message to display if the assertion fails.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @method datesAreEqual
0fc5ce7045233dae7e15fdc86774370f1b1d73cbjohanengelen datesAreEqual : function (expected, actual, message){
0fc5ce7045233dae7e15fdc86774370f1b1d73cbjohanengelen if (expected instanceof Date && actual instanceof Date){
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm //check years first
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm //now check months
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm //last, check the day of the month
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm throw new Y.Assert.ComparisonFailure(Y.Assert._formatMessage(message, msg), expected, actual);
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm throw new TypeError("Y.Assert.datesAreEqual(): Expected and actual values must be Date objects.");
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * Asserts that a date's hour, minutes, and seconds are equal to another date's.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @param {Date} expected The expected date.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @param {Date} actual The actual date to test.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @param {String} message (Optional) The message to display if the assertion fails.
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm * @method timesAreEqual
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm if (expected instanceof Date && actual instanceof Date){
0fc5ce7045233dae7e15fdc86774370f1b1d73cbjohanengelen //check hours first
f07bfd5a05d43a6d11f7cd442f085149092dea88pjrm //now check minutes
throw new TypeError("DateY.AsserttimesAreEqual(): Expected and actual values must be Date objects.");