var element = document.querySelector('.CalendarBase > input');
console.log(element);
const digitsMask = IMask(element, {
mask: Date, // enable date mask
// other options are optional
pattern: 'Y - `Y `', // Pattern mask with defined blocks, default is 'd{.}`m{.}`Y'
// you can provide your own blocks definitions, default blocks for date mask are:
blocks: {
Y: {
mask: IMask.MaskedRange,
from: 1900,
to: 2024,
}
},
// define date -> str convertion
format: date => {
let day = date.getDate();
let month = date.getMonth() + 1;
const year = date.getFullYear();
if (day < 10) day = "0" + day;
if (month < 10) month = "0" + month;
return [year, month, day].join('-');
},
// define str -> date convertion
parse: str => {
const yearMonthDay = str.split('-');
return new Date(yearMonthDay[0], yearMonthDay[1] - 1, yearMonthDay[2]);
},
// optional interval options
min: new Date(2000, 0, 1), // defaults to `1900-01-01`
max: new Date(2020, 0, 1), // defaults to `9999-01-01`
autofix: true, // defaults to `false`
// pattern options can be set as well
lazy: true,
// and other common options
overwrite: true // defaults to `false`
})
});```