mikecoj / MCDatepicker

A vanilla JavaScript Datepicker
https://mcdatepicker.netlify.app/
MIT License
93 stars 18 forks source link

customWeekDays not work #80

Closed enricodeveloper closed 2 years ago

enricodeveloper commented 2 years ago

customWeekDays: ['D', 'L', 'M', 'M', 'G', 'V', 'S'] for italian language not work

error: Cannot read properties of undefined (reading 'allowedYears')

ashenshugarRET commented 2 years ago

Can you upload your code specifying the options for your datepicker? If customWeekDays is not the last item in the list make sure you have a comma at the end if the line...

enricodeveloper commented 2 years ago

Can you upload your code specifying the options for your datepicker? If customWeekDays is not the last item in the list make sure you have a comma at the end if the line...

<input id="cin" type="text" class="custom-select11" name="cin" />

const myDatePicker = MCDatepicker.create({ el: '#cin', autoClose: true, closeOnBlur: true, dateFormat: 'dd/mm/yyyy', minDate: new Date(yyyy, mm, gg), customWeekDays: ['D', 'L', 'M', 'M', 'G', 'V', 'S'], customMonths: [ 'Gennaio', 'Febbraio', 'Marzo', 'Aprile', 'Maggio', 'Giugno', 'Luglio', 'Agosto', 'Settembre', 'Ottobre', 'Novembre', 'Dicembre' ] })

ashenshugarRET commented 2 years ago

Thanks,

Can you try by using the full word for each day rather than a single letter? Also have you declared yyyy, mm and gg as variables as minDate needs to refer to a specific date rather than date formatting?

enricodeveloper commented 2 years ago

Thanks,

Can you try by using the full word for each day rather than a single letter? Also have you declared yyyy, mm and gg as variables as minDate needs to refer to a specific date rather than date formatting?

I solved. Now I have another problem with minDate: new Date (yyyy, mm, dd),

yyyy = 2022 - mm = 06 - dd = 19

the calendar starts with the following month

Thank you

ashenshugarRET commented 2 years ago

OK, so that is caused by a peculiarity of how javascript handles dates (see: https://javascript.info/date), so in your example, you could create a string from your variables ie dateString = yyyy + "-" + mm + "-" + dd; then use that for your minDate: minDate: new Date (dateString),

or you could just subtract 1 from your mm value...

enricodeveloper commented 2 years ago

OK, so that is caused by a peculiarity of how javascript handles dates (see: https://javascript.info/date), so in your example, you could create a string from your variables ie dateString = yyyy + "-" + mm + "-" + dd; then use that for your minDate: minDate: new Date (dateString),

or you could just subtract 1 from your mm value...

Perfect

Thank you :)

ashenshugarRET commented 2 years ago

If your problem has been solved could you close the issue?