]> git.ipfire.org Git - thirdparty/moment.git/commitdiff
Updated regex to support + sign in between the string
authorKshitij <kshitij.inbox@gmail.com>
Wed, 14 Jun 2017 08:26:16 +0000 (13:56 +0530)
committerIskren Chernev <iskren.chernev@gmail.com>
Mon, 7 Aug 2017 00:44:48 +0000 (03:44 +0300)
src/lib/duration/create.js

index 656fb233779d0b3ba673327fb537d0991d90eaeb..e6d51cd7d12ee8be51e3f65f3a9192cad84a8b80 100644 (file)
@@ -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,