
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;