]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Further trial
authorTGJG-XPS\TracyG <tracyg.gilmore@gmail.com>
Sat, 4 Feb 2017 13:15:12 +0000 (13:15 +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 b5b87463ddb1d104903da5a3770042d2054ca09a..1da560ddf413a48a9e4e2820128ed072a17401a9 100644 (file)
@@ -1,5 +1,6 @@
 import { configFromStringAndFormat } from './from-string-and-format';
 import { hooks } from '../utils/hooks';
+import moment from '../moment';     // Needed for RFC2822 validation of weekday
 import { deprecate } from '../utils/deprecate';
 import getParsingFlags from './parsing-flags';
 
@@ -160,6 +161,9 @@ 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]) { // day of week given
             console.log('[' + match[1].substr(0,3) + ']', moment(match[2], dateFormat).format('ddd'));
             var momentDay = moment(match[2], dateFormat).format('ddd');
@@ -169,6 +173,8 @@ export function configFromRFC2822(config) {
                 return;
             }
         }
+        /* */
+       
         getParsingFlags(config).rfc2822 = true;
 
         switch (match[5].length) {
index 679ae18f51599e8644a84f6db2284535bc011ab6..6acf8518c749b08cfff9d26267f0e28a68455df7 100644 (file)
@@ -476,8 +476,10 @@ 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) {