From: TGJG-XPS\TracyG Date: Sat, 4 Feb 2017 13:08:49 +0000 (+0000) Subject: Trial validation of weekday X-Git-Tag: 2.18.0~12^2~28 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=b3048d737737bf7d254b11334df1f6cdf1e6088d;p=thirdparty%2Fmoment.git Trial validation of weekday --- diff --git a/src/lib/create/from-string.js b/src/lib/create/from-string.js index 34063cbb8..b5b87463d 100644 --- a/src/lib/create/from-string.js +++ b/src/lib/create/from-string.js @@ -160,17 +160,15 @@ export function configFromRFC2822(config) { dateFormat = 'D MMM ' + ((match[2].length > 10) ? 'YYYY ' : 'YY '); timeFormat = 'HH:mm' + (match[4] ? ':ss' : ''); - // TODO Confirm the given day-of-week is consistent with the day-of-month-year - // NB: Needs an instance of moment, created from the date element of the input string. - /* - if (match[1]) { + if (match[1]) { // day of week given console.log('[' + match[1].substr(0,3) + ']', moment(match[2], dateFormat).format('ddd')); - if (match[1].substr(0,3) !== this(match[2], dateFormat).format('ddd')) { + var momentDay = moment(match[2], dateFormat).format('ddd'); + + if (match[1].substr(0,3) !== momentDay) { config._isValid = false; return; } } - */ getParsingFlags(config).rfc2822 = true; switch (match[5].length) { diff --git a/src/test/moment/create.js b/src/test/moment/create.js index 5788480ce..679ae18f5 100644 --- a/src/test/moment/create.js +++ b/src/test/moment/create.js @@ -476,10 +476,8 @@ test('parsing RFC 2822', function (assert) { test('non RFC 2822 strings', function (assert) { assert.ok(!moment('Tue. 01 Nov 2016 01:23:45 GMT', moment.RFC_2822, true).isValid(), 'RFC2822 datetime with all options but invalid day delimiter'); - /* assert.ok(!moment('Mon, 01 Nov 2016 01:23:45 GMT', moment.RFC_2822, true).isValid(), 'RFC2822 datetime with mismatching Day (week v date)'); - */ }); test('parsing iso', function (assert) {