]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Trial validation of weekday
authorTGJG-XPS\TracyG <tracyg.gilmore@gmail.com>
Sat, 4 Feb 2017 13:08:49 +0000 (13:08 +0000)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 12 Mar 2017 00:11:46 +0000 (02:11 +0200)
src/lib/create/from-string.js
src/test/moment/create.js

index 34063cbb87b721149ec0f96d097d4f1788875ae8..b5b87463ddb1d104903da5a3770042d2054ca09a 100644 (file)
@@ -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) {
index 5788480ce6f4f4284a09e8788f7d887245c202e0..679ae18f51599e8644a84f6db2284535bc011ab6 100644 (file)
@@ -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) {