Files
safekat/httpdocs/assets/js/safekat/components/datepicker.js
2025-01-02 10:50:56 +01:00

28 lines
707 B
JavaScript

import { Spanish } from "../../../../themes/vuexy/vendor/libs/flatpickr/es.js"
class DatePicker {
constructor(domItem, options) {
this.item = domItem
this.options = options
this.itemDate = null;
this.init()
}
init() {
this.itemDate = this.item.flatpickr({ ...this.options, locale: Spanish })
}
setDateFormat(dateFormat = "dd/mm/yy") {
this.item.flatpickr("option", "dateFormat", dateFormat)
}
getDate() {
return this.itemDate.getDate()
}
setDate(date) {
if(!isNaN(new Date(date))){
this.itemDate.setDate(date,true,this.options.dateFormat)
}
}
}
export default DatePicker;