theroozbeh / vue2-persian-datepicker

A vue component that provides datepicker for persian developers
MIT License
99 stars 18 forks source link

Setting availableDateEnd Shows year 1300 in openDialog #34

Closed rahimramezanian closed 4 years ago

rahimramezanian commented 4 years ago

If I set availableDates="true" when we open the dialog to chnage the map by default it shows first month of year 1300.

<pdatepicker :modal-mode="true" :placeholder="someDay" :availableDates="true" :availableDateEnd="someEndDay" @selected="someEvent"/>

Screenshot from 2020-01-07 15-29-58

rahimramezanian commented 4 years ago

In https://github.com/dyonir/vue2-persian-datepicker/blob/44f38f2ed821db2c468045f167c61922063936da/src/components/PDatePicker.vue part mounted change the code below

    if(this.inputCheck(this.value)){
        this.inputChanged(this.value);
    } else if(this.isToDayInRange()){
        this.goToToday();
    } else {
        this.goToMonth(this.startAvailableDateV.year , this.startAvailableDateV.month - 1, this.startAvailableDateV.day);
    }

to

    if(this.inputCheck(this.value)){
        this.inputChanged(this.value);
    } else if(this.isToDayInRange()){
        this.goToToday();
    } else {
        let ymd = this.availableDateEnd.split("/").map(x => parseInt(x));
        this.goToMonth(ymd[0] , ymd[1]-1, ymd[2]);
    }

Screenshot from 2020-01-07 15-41-51