Fix set_min() & set_max() for Date

This commit is contained in:
nathan 2022-03-07 14:33:09 -07:00
parent 3c656701f5
commit d0926226cd

View File

@ -435,6 +435,17 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
this.minDate = min;
}
set minDate(min : string | Date)
{
if(this._instance)
{
// Handle timezone offset, flatpickr uses local time
let date = new Date(min);
let formatDate = new Date(date.valueOf() + date.getTimezoneOffset() * 60 * 1000);
this._instance.set('minDate', formatDate)
}
}
/**
* Set the minimum allowed date
* @param {string | Date} max
@ -444,6 +455,17 @@ export class Et2Date extends Et2InputWidget(FormControlMixin(ValidateMixin(LitFl
this.maxDate = max;
}
set maxDate(max : string | Date)
{
if(this._instance)
{
// Handle timezone offset, flatpickr uses local time
let date = new Date(max);
let formatDate = new Date(date.valueOf() + date.getTimezoneOffset() * 60 * 1000);
this._instance.set('maxDate', formatDate)
}
}
/**
* Override from flatpickr
* @returns {any}