From aa21929801df92cdb8e5f3f456fff7ff0a186cc3 Mon Sep 17 00:00:00 2001 From: "Paul M. Christian" Date: Tue, 31 Oct 2017 15:35:07 -0500 Subject: [PATCH] fix utils.getMonthsForYear() to account for months shorter than that of the selected date; resolves #140 --- src/utils/index.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/utils/index.js b/src/utils/index.js index f7c3211f..ded9ffa6 100644 --- a/src/utils/index.js +++ b/src/utils/index.js @@ -157,7 +157,10 @@ export function getDateString(year, month, date) { } export function getMonthsForYear(year, day = 1) { - return Array.apply(null, Array(12)).map((val, index) => new Date(year, index, day)); + return Array.apply(null, Array(12)).map((val, index) => { + const constrainedDay = Math.min(getDaysInMonth(new Date(year, index, 1)), day); + return new Date(year, index, constrainedDay); + }); } export const withImmutableProps = (props) => withPropsOnChange(() => false, props);