From 80d1e1588357f29f3c600932d0b3df54274491af Mon Sep 17 00:00:00 2001 From: "TGJG-XPS\\TracyG" Date: Mon, 6 Mar 2017 21:47:06 +0000 Subject: [PATCH] Enhanced positive test cases to include a variety of time zone/offsets. Made the military time zone case insensitive in line with specification. --- src/lib/create/from-string.js | 4 ++-- src/test/moment/create.js | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/lib/create/from-string.js b/src/lib/create/from-string.js index b7ba9a740..cc7c3592d 100644 --- a/src/lib/create/from-string.js +++ b/src/lib/create/from-string.js @@ -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'; } diff --git a/src/test/moment/create.js b/src/test/moment/create.js index 89cf5f407..5728470c4 100644 --- a/src/test/moment/create.js +++ b/src/test/moment/create.js @@ -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)' }; -- 2.47.2