qodesmith / datepicker

Get a date with JavaScript! A datepicker with no dependencies.
344 stars 101 forks source link

more weeks are shown #86

Closed Danaika closed 4 years ago

Danaika commented 4 years ago

Thank You very much for your “js-datepicker”!!! I used this datepicker(Version 5.6.0) in my project. I installed it manually. Unfortunately, I found some problem: datepicker shows more weeks than it has to, in some month. For example: in June 2020 we will have 5 weeks, but datepicker shows 6 weeks. Here is code:

const picker = datepicker('#calendar_input', {
    onSelect: (instance, date) => { },
    formatter: (input, date, instance) => {
      let d = new Date();
      let dd = date.getDate()<=9 ? '0'+(date.getDate()):(date.getDate());
      let mm = date.getMonth()<9?'0'+(date.getMonth() + 1):date.getMonth() + 1  ; //Months are zero based
      let yyyy = date.getFullYear();
      input.value = dd+'.'+mm+'.'+yyyy
    },
    startDay: 1,
    customDays: ['Вс', 'Пн', 'Вт', 'Ср', 'Чт', 'Пт', 'Сб'],
    customMonths: ['Январь', 'Февраль', 'Март', 'Апрель', 'Май', 'Июнь', 'Июль', 'Август', 'Сентябрь', 'Октябрь', 'Ноябрь', 'Декабрь'],
    customOverlayMonths:['Янв', 'Фев', 'Март', 'Апр', 'Май', 'Июнь', 'Июль', 'Авг', 'Сен', 'Окт', 'Нояб', 'Дек'],
    showAllDates: true,
    overlayButton: 'Готово',
    overlayPlaceholder: 'Введите год'
  });

Some screenshots are attached below.

Screen Shot 2020-04-22 at 16 39 35 Screen Shot 2020-04-22 at 16 40 40
Danaika commented 4 years ago

P.S.: In first screenshot June 2020 is shown, in second screenshot - March 2021

qodesmith commented 4 years ago

Hey @Danaika. So in looking into the code, I found this line that's causing the problem. I remember having to add it a while ago, but can't figure out why I did so! I'm playing around now to figure this out. Stay tuned!

qodesmith commented 4 years ago

@Danaika Ok, this should be fixed now. Let me know if you still have issues!

Danaika commented 4 years ago

It's great! Thank You!!! I tested new version - it's ok!