bleenco / ng2-datepicker

Angular2 Datepicker Component
http://ng2-datepicker.jankuri.com
MIT License
313 stars 236 forks source link

Incorrect Date with firstCalendarDay 1 (1st April 2018) #297

Open strad84 opened 6 years ago

strad84 commented 6 years ago

Hi,

with firstCalendarDay 1 there is an issue on 1st April 2018,

datepicker issue

For calendar 1st April is Monday but actually will be Sunday.

Thank you

strad84 commented 6 years ago

i've done this temporary fix

const tmp = getDay(start) - this.firstCalendarDay; const prevDays = tmp < 0 ? 7 - this.firstCalendarDay : tmp;

for (let i = 1; i <= prevDays; i++) {
  const date = subDays(start, i);
  this.days.unshift({
    date: date,
    day: getDate(date),
    month: getMonth(date),
    year: getYear(date),
    inThisMonth: false,
    isToday: isToday(date),
    isSelected: isSameDay(date, this.innerValue) && isSameMonth(date, this.innerValue) && isSameYear(date, this.innerValue),
    isSelectable: this.isDateSelectable(date)
  });
}
jkuri commented 6 years ago

hi. thanks... can you make a PR with the fix?

strad84 commented 6 years ago

Done! I hope i've done it properly.

Thanks!

Inviato da ProtonMail mobile

-------- Messaggio originale -------- On 23 gen 2018, 12:29, Jan Kuri ha scritto:

hi. thanks... can you make a PR with the fix?

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or mute the thread.