Skip to content

Commit

Permalink
Add range-start and range-end class in month range (Hacker0x01#1794)
Browse files Browse the repository at this point in the history
  • Loading branch information
thoaihuynh2509 authored and martijnrusschen committed Jun 25, 2019
1 parent 51ed59a commit 356ced8
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion src/month.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,22 @@ export default class Month extends React.Component {
}
};

isRangeStart = () => {
const { day, startDate, endDate } = this.props;
if (!startDate || !endDate) {
return false;
}
return utils.isSameMonth(startDate, day);
};

isRangeEnd = () => {
const { day, startDate, endDate } = this.props;
if (!startDate || !endDate) {
return false;
}
return utils.isSameMonth(endDate, day);
};

isWeekInMonth = startOfWeek => {
const day = this.props.day;
const endOfWeek = utils.addDays(startOfWeek, 6);
Expand Down Expand Up @@ -161,7 +177,9 @@ export default class Month extends React.Component {
endDate,
m,
day
)
),
"react-datepicker__month--range-start": this.isRangeStart(),
"react-datepicker__month--range-end": this.isRangeEnd(),
}
);
};
Expand Down

0 comments on commit 356ced8

Please sign in to comment.