|
@@ -32,53 +32,59 @@ class DateObject {
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
initDateObject(mask, opts, inputmask) {
|
|
initDateObject(mask, opts, inputmask) {
|
|
|
- let match;
|
|
|
|
|
|
|
+ let match,
|
|
|
|
|
+ lastNdx = -1;
|
|
|
getTokenizer(opts).lastIndex = 0;
|
|
getTokenizer(opts).lastIndex = 0;
|
|
|
while ((match = getTokenizer(opts).exec(this.format))) {
|
|
while ((match = getTokenizer(opts).exec(this.format))) {
|
|
|
- let dynMatches = /\d+$/.exec(match[0]),
|
|
|
|
|
- fcode = dynMatches ? match[0][0] + "x" : match[0],
|
|
|
|
|
- value;
|
|
|
|
|
- if (mask !== undefined) {
|
|
|
|
|
- // console.log("mask", mask);
|
|
|
|
|
- if (dynMatches) {
|
|
|
|
|
- const lastIndex = getTokenizer(opts).lastIndex,
|
|
|
|
|
- tokenMatch = getTokenMatch.call(
|
|
|
|
|
- inputmask,
|
|
|
|
|
- match.index,
|
|
|
|
|
- opts,
|
|
|
|
|
- inputmask && inputmask.maskset
|
|
|
|
|
|
|
+ if (match.index >= lastNdx) {
|
|
|
|
|
+ let dynMatches = /\d+$/.exec(match[0]),
|
|
|
|
|
+ fcode = dynMatches ? match[0][0] + "x" : match[0],
|
|
|
|
|
+ value;
|
|
|
|
|
+ if (mask !== undefined) {
|
|
|
|
|
+ // console.log("mask", mask);
|
|
|
|
|
+ if (dynMatches) {
|
|
|
|
|
+ const lastIndex = getTokenizer(opts).lastIndex,
|
|
|
|
|
+ tokenMatch = getTokenMatch.call(
|
|
|
|
|
+ inputmask,
|
|
|
|
|
+ match.index,
|
|
|
|
|
+ opts,
|
|
|
|
|
+ inputmask && inputmask.maskset
|
|
|
|
|
+ );
|
|
|
|
|
+ getTokenizer(opts).lastIndex = lastIndex;
|
|
|
|
|
+ value = mask.slice(0, mask.indexOf(tokenMatch.nextMatch[0]));
|
|
|
|
|
+ } else {
|
|
|
|
|
+ let targetSymbol = match[0][0],
|
|
|
|
|
+ ndx = match.index;
|
|
|
|
|
+ while (
|
|
|
|
|
+ inputmask &&
|
|
|
|
|
+ (opts.placeholder[
|
|
|
|
|
+ getTest.call(inputmask, ndx).match.placeholder
|
|
|
|
|
+ ] || getTest.call(inputmask, ndx).match.placeholder) ===
|
|
|
|
|
+ targetSymbol
|
|
|
|
|
+ ) {
|
|
|
|
|
+ ndx++;
|
|
|
|
|
+ }
|
|
|
|
|
+ lastNdx = ndx;
|
|
|
|
|
+ const targetMatchLength = ndx - match.index;
|
|
|
|
|
+ value = mask.slice(
|
|
|
|
|
+ 0,
|
|
|
|
|
+ targetMatchLength ||
|
|
|
|
|
+ (formatCode[fcode] && formatCode[fcode][4]) ||
|
|
|
|
|
+ fcode.length
|
|
|
);
|
|
);
|
|
|
- getTokenizer(opts).lastIndex = lastIndex;
|
|
|
|
|
- value = mask.slice(0, mask.indexOf(tokenMatch.nextMatch[0]));
|
|
|
|
|
- } else {
|
|
|
|
|
- let targetSymbol = match[0][0],
|
|
|
|
|
- ndx = match.index;
|
|
|
|
|
- while (
|
|
|
|
|
- inputmask &&
|
|
|
|
|
- (opts.placeholder[getTest.call(inputmask, ndx).match.placeholder] ||
|
|
|
|
|
- getTest.call(inputmask, ndx).match.placeholder) === targetSymbol
|
|
|
|
|
- ) {
|
|
|
|
|
- ndx++;
|
|
|
|
|
}
|
|
}
|
|
|
- const targetMatchLength = ndx - match.index;
|
|
|
|
|
- value = mask.slice(
|
|
|
|
|
- 0,
|
|
|
|
|
- targetMatchLength ||
|
|
|
|
|
- (formatCode[fcode] && formatCode[fcode][4]) ||
|
|
|
|
|
- fcode.length
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ mask = mask.slice(value.length);
|
|
|
}
|
|
}
|
|
|
- mask = mask.slice(value.length);
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
- if (Object.prototype.hasOwnProperty.call(formatCode, fcode)) {
|
|
|
|
|
- this.setValue(
|
|
|
|
|
- this,
|
|
|
|
|
- value,
|
|
|
|
|
- fcode,
|
|
|
|
|
- formatCode[fcode][2],
|
|
|
|
|
- formatCode[fcode][1]
|
|
|
|
|
- );
|
|
|
|
|
|
|
+ if (Object.prototype.hasOwnProperty.call(formatCode, fcode)) {
|
|
|
|
|
+ this.setValue(
|
|
|
|
|
+ this,
|
|
|
|
|
+ value,
|
|
|
|
|
+ fcode,
|
|
|
|
|
+ formatCode[fcode][2],
|
|
|
|
|
+ formatCode[fcode][1]
|
|
|
|
|
+ );
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|