Skip to content

Commit

Permalink
Fix #3125: Calendar min/max corrected (#3126)
Browse files Browse the repository at this point in the history
  • Loading branch information
melloware authored Aug 2, 2022
1 parent 86637af commit 420dc32
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions components/lib/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -975,7 +975,13 @@ export const Calendar = React.memo(React.forwardRef((props, ref) => {
// previous (check first day of month at 00:00:00)
if (props.minDate) {
let firstDayOfMonth = new Date(newViewDate.getTime());
firstDayOfMonth.setDate(1);
if (firstDayOfMonth.getMonth() === 0) {
firstDayOfMonth.setMonth(11, 1);
firstDayOfMonth.setFullYear(firstDayOfMonth.getFullYear() - 1);
}
else {
firstDayOfMonth.setMonth(firstDayOfMonth.getMonth() - 1, 1);
}
firstDayOfMonth.setHours(0);
firstDayOfMonth.setMinutes(0);
firstDayOfMonth.setSeconds(0);
Expand All @@ -989,8 +995,13 @@ export const Calendar = React.memo(React.forwardRef((props, ref) => {
// next (check last day of month at 11:59:59)
if (props.maxDate) {
let lastDayOfMonth = new Date(newViewDate.getTime());
lastDayOfMonth.setMonth(lastDayOfMonth.getMonth()+1);
lastDayOfMonth.setDate(1);
if (lastDayOfMonth.getMonth() === 11) {
lastDayOfMonth.setMonth(0, 1);
lastDayOfMonth.setFullYear(lastDayOfMonth.getFullYear() + 1);
}
else {
lastDayOfMonth.setMonth(lastDayOfMonth.getMonth() + 1, 1);
}
lastDayOfMonth.setHours(0);
lastDayOfMonth.setMinutes(0);
lastDayOfMonth.setSeconds(0)
Expand Down

0 comments on commit 420dc32

Please sign in to comment.