From: Kshitij Date: Tue, 1 Aug 2017 11:16:41 +0000 (+0530) Subject: Using character class instead of non capturing group X-Git-Tag: 2.19.0~24^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4025ba457b82f88489897d4944ad4283508008ff;p=thirdparty%2Fmoment.git Using character class instead of non capturing group --- diff --git a/src/lib/duration/create.js b/src/lib/duration/create.js index e6d51cd7d..346814816 100644 --- a/src/lib/duration/create.js +++ b/src/lib/duration/create.js @@ -14,7 +14,7 @@ var aspNetRegex = /^(\-|\+)?(?:(\d*)[. ])?(\d+)\:(\d+)(?:\:(\d+)(\.\d*)?)?$/; // from http://docs.closure-library.googlecode.com/git/closure_goog_date_date.js.source.html // somewhat more in line with 4.4.3.2 2004 spec, but allows decimal anywhere // and further modified to allow for strings containing both week and day -var isoRegex = /^(-|\+)?P(?:((?:-|\+)?[0-9,.]*)Y)?(?:((?:-|\+)?[0-9,.]*)M)?(?:((?:-|\+)?[0-9,.]*)W)?(?:((?:-|\+)?[0-9,.]*)D)?(?:T(?:((?:-|\+)?[0-9,.]*)H)?(?:((?:-|\+)?[0-9,.]*)M)?(?:((?:-|\+)?[0-9,.]*)S)?)?$/; +var isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/; export function createDuration (input, key) { var duration = input, @@ -38,7 +38,7 @@ export function createDuration (input, key) { duration.milliseconds = input; } } else if (!!(match = aspNetRegex.exec(input))) { - sign = (match[1] === '-') ? -1 : (match[1] === '+') ? 1 : 1; + sign = (match[1] === '-') ? -1 : 1; duration = { y : 0, d : toInt(match[DATE]) * sign,