|
|
@@ -99,7 +99,7 @@ class DateObject {
|
|
|
if (targetProp === "month") useDateObject = true;
|
|
|
if (targetProp === "year") {
|
|
|
useDateObject = true;
|
|
|
- if (datavalue.length < 4) datavalue = pad(datavalue, 4, true);
|
|
|
+ if (datavalue.length < formatCode[fcode][4]) datavalue = pad(datavalue, formatCode[fcode][4], true);
|
|
|
}
|
|
|
if ((datavalue !== "" && !isNaN(datavalue)) || targetProp === "ampm") dateOperation.call(dateObj._date, datavalue);
|
|
|
}
|
|
|
@@ -151,12 +151,15 @@ let currentYear = new Date().getFullYear(), i18n = Inputmask.prototype.i18n, use
|
|
|
}, "month", function () {
|
|
|
return i18n.monthNames.slice(12, 24)[Date.prototype.getMonth.call(this)];
|
|
|
}], //Month as its full name.
|
|
|
- yy: ["[0-9]{2}", Date.prototype.setFullYear, "year", function () {
|
|
|
+ yy: ["[0-9]{2}", function (val) {
|
|
|
+ const centuryPart = new Date().getFullYear().toString().slice(0, 2);
|
|
|
+ Date.prototype.setFullYear.call(this, `${centuryPart}${val}`);
|
|
|
+ }, "year", function () {
|
|
|
return pad(Date.prototype.getFullYear.call(this), 2);
|
|
|
- }], //Year as last two digits; leading zero for years less than 10.
|
|
|
+ }, 2], //Year as last two digits; leading zero for years less than 10.
|
|
|
yyyy: ["[0-9]{4}", Date.prototype.setFullYear, "year", function () {
|
|
|
return pad(Date.prototype.getFullYear.call(this), 4);
|
|
|
- }], h: ["[1-9]|1[0-2]", Date.prototype.setHours, "hours", Date.prototype.getHours], //Hours; no leading zero for single-digit hours (12-hour clock).
|
|
|
+ }, 4], h: ["[1-9]|1[0-2]", Date.prototype.setHours, "hours", Date.prototype.getHours], //Hours; no leading zero for single-digit hours (12-hour clock).
|
|
|
hh: ["0[1-9]|1[0-2]", Date.prototype.setHours, "hours", function () {
|
|
|
return pad(Date.prototype.getHours.call(this), 2);
|
|
|
}], //Hours; leading zero for single-digit hours (12-hour clock).
|
|
|
@@ -324,7 +327,7 @@ function isDateInRange(dateParts, result, opts, maskset, fromCheckval) {
|
|
|
if (fcode[3]) {
|
|
|
var setFn = fcode[1];
|
|
|
var current = dateParts[fcode[2]], minVal = opts.min[fcode[2]],
|
|
|
- maxVal = opts.max ? opts.max[fcode[2]] : minVal, curVal = [];
|
|
|
+ maxVal = opts.max ? opts.max[fcode[2]] : minVal + 1, curVal = [];
|
|
|
|
|
|
let forceCurrentValue = false;
|
|
|
for (let i = 0; i < minVal.length; i++) {
|
|
|
@@ -402,7 +405,7 @@ function parse(format, dateObjValue, opts, raw) {
|
|
|
}
|
|
|
ndx++;
|
|
|
}
|
|
|
- if (dateObjValue === undefined && (opts.placeholder === "" || opts.inputFormat.indexOf("mmmm") != -1)) {
|
|
|
+ if (dateObjValue === undefined && (opts.placeholder === "" || opts.inputFormat.indexOf("mmmm") !== -1)) {
|
|
|
opts.placeholder = placeHolder;
|
|
|
}
|
|
|
return mask;
|