* Check that day-of-week matches parsed date in configFromArray
* Add tests
if (config._nextDay) {
config._a[HOUR] = 24;
}
+
+ // check for mismatching day of week
+ if (config._w && typeof config._w.d !== 'undefined' && config._w.d !== config._d.getDay()) {
+ getParsingFlags(config).weekdayMismatch = true;
+ }
}
function dayOfYearFromWeekInfo(config) {
!flags.empty &&
!flags.invalidMonth &&
!flags.invalidWeekday &&
+ !flags.weekdayMismatch &&
!flags.nullInput &&
!flags.invalidFormat &&
!flags.userInvalidated &&
}
});
+test('mismatching day-of-week and date', function (assert) {
+ assert.ok(!moment('Wed 08-10-2017', 'ddd MM-DD-YYYY').isValid(), 'because the day-of-the-week is incorrect for the date');
+ assert.ok(moment('Thu 08-10-2017', 'ddd MM-DD-YYYY').isValid(), 'because the day-of-the-week is correct for the date');
+});
+