react-infinite-calendar icon indicating copy to clipboard operation
react-infinite-calendar copied to clipboard

fix utils.getMonthsForYear() to account for months shorter than that …

Open meta-meta opened this issue 6 years ago • 3 comments

…of the selected date; resolves #140

meta-meta avatar Oct 31 '17 20:10 meta-meta

Hmm, would you care to elaborate a little about this solution?

clauderic avatar Nov 01 '17 16:11 clauderic

new Date(2017, 1, 28) Tue Feb 28 2017 00:00:00 GMT-0600 (Central Standard Time) new Date(2017, 1, 31) Fri Mar 03 2017 00:00:00 GMT-0600 (Central Standard Time)

If the day passed to getMonthsForYear is greater than the number of days in that month, you end up getting the following month. Result being in your year view, you end up with Jan Mar Mar May May...

So the proposed solution is to constrain the day to fall within the month. Math.min returns the lesser of n values.

meta-meta avatar Nov 01 '17 17:11 meta-meta

Hi, is there any plan to merge this PR?

fra-smw avatar Nov 21 '17 11:11 fra-smw