]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Enhanced positive test cases to include a variety of time zone/offsets.
authorTGJG-XPS\TracyG <tracyg.gilmore@gmail.com>
Mon, 6 Mar 2017 21:47:06 +0000 (21:47 +0000)
committerIskren Chernev <iskren.chernev@gmail.com>
Sun, 12 Mar 2017 00:11:46 +0000 (02:11 +0200)
Made the military time zone case insensitive in line with specification.

src/lib/create/from-string.js
src/test/moment/create.js

index b7ba9a740b51bc366238239ed3ca0a06f9cb3267..cc7c3592dda222fd582cd7550af3e27b7896a179 100644 (file)
@@ -94,7 +94,7 @@ export function configFromISO(config) {
 }
 
 // RFC 2822 regex: For details see https://tools.ietf.org/html/rfc2822#section-3.3
-var basicRfcRegex = /^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Z]|[+-]\d{4}))$/;
+var basicRfcRegex = /^((?:Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d?\d\s(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?:\d\d)?\d\d\s)(\d\d:\d\d)(\:\d\d)?(\s(?:UT|GMT|[ECMP][SD]T|[A-IK-Z]|[a-ik-z]|[+-]\d{4}))$/;
 
 // date and time from ref 2822 format
 export function configFromRFC2822(config) {
@@ -142,7 +142,7 @@ export function configFromRFC2822(config) {
                 if (timezoneIndex === 0) {
                     timezone = ' +0000';
                 } else {
-                    timezoneIndex = military.indexOf(match[5][1]) - 12;
+                    timezoneIndex = military.indexOf((match[5][1]).toUpperCase()) - 12;
                     timezone = ((timezoneIndex < 0) ? ' -' : ' +') +
                         (('' + timezoneIndex).replace(/^-?/, '0')).match(/..$/)[0] + '00';
                 }
index 89cf5f407fd52b1aaf09069d7ab30158f7b52355..5728470c49644edfda0e326f537fb46b86c53bab 100644 (file)
@@ -458,11 +458,11 @@ test('cloning carrying over utc mode', function (assert) {
 
 test('parsing RFC 2822', function (assert) {
     var testCases = {
-        'clean RFC2822 datetime with all options': 'Tue, 01 Nov 2016 01:23:45 GMT',
+        'clean RFC2822 datetime with all options': 'Tue, 01 Nov 2016 01:23:45 UT',
         'clean RFC2822 datetime without comma': 'Tue 01 Nov 2016 01:23:45 GMT',
-        'clean RFC2822 datetime without seconds': 'Tue, 01 Nov 2016 01:23 GMT',
-        'clean RFC2822 datetime without century': 'Tue, 01 Nov 16 01:23:45 GMT',
-        'clean RFC2822 datetime without day': '01 Nov 2016 01:23:45 GMT',
+        'clean RFC2822 datetime without seconds': 'Tue, 01 Nov 2016 01:23 +0000',
+        'clean RFC2822 datetime without century': 'Tue, 01 Nov 16 01:23:45 Z',
+        'clean RFC2822 datetime without day': '01 Nov 2016 01:23:45 z',
         'clean RFC2822 datetime with single-digit day-of-month': 'Tue, 1 Nov 2016 01:23:45 GMT',
         'RFC2822 datetime with CFWSs': '(Init Comment) Tue,\n 1 Nov              2016 (Split\n Comment)  01:23:45 +0000 (GMT)'
     };