Skip to content

Commit

Permalink
fix utils.getMonthsForYear() to account for months shorter than that …
Browse files Browse the repository at this point in the history
…of the selected date; resolves clauderic#140
  • Loading branch information
meta-meta committed Oct 31, 2017
1 parent c776d13 commit aa21929
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/utils/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit aa21929

Please sign in to comment.