onesine / react-tailwindcss-datepicker

Modern date range picker component for React using Tailwind 3 and dayjs. Alternative to Litepie Datepicker.
https://react-tailwindcss-datepicker.vercel.app/
MIT License
552 stars 170 forks source link

Calendar not showing previous month when using different dayjs.locale() #221

Closed cheeselemon closed 3 months ago

cheeselemon commented 11 months ago

If you declare dayjs.locale() somewhere alongside using this library, the weekday matching function below will fail:

react-tailwindcss-datepicker/src/helpers/index.ts

Line 174 in bf063fe

["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"].forEach( because the date argument provided using getFirstDayInMonth(date).ddd will return what was defined through dayjs.locale() other than "en" will return non english weekday string, thus won't match anything so the variable number will always be zero.

I'm implementing a fix, and will update with a pull request.

See related: #150

onesine commented 3 months ago

Thanks @cheeselemon for the contribution.