Skip to content

Commit

Permalink
Refactor #5886
Browse files Browse the repository at this point in the history
  • Loading branch information
tugcekucukoglu committed Jun 27, 2024
1 parent 8416ec6 commit c70a9e8
Showing 1 changed file with 5 additions and 11 deletions.
16 changes: 5 additions & 11 deletions packages/primevue/src/datepicker/DatePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -720,20 +720,14 @@ export default {
if (!this.isComparable()) return false;
if (this.isMultipleSelection()) {
return this.modelValue.some((v) => v.getMonth() === month && v.getFullYear() === this.currentYear);
return this.modelValue.some((currentValue) => currentValue.getMonth() === month && currentValue.getFullYear() === this.currentYear);
} else if (this.isRangeSelection()) {
const [start, end] = this.modelValue;
const startYear = start ? start.getFullYear() : null;
const endYear = end ? end.getFullYear() : null;
const startMonth = start ? start.getMonth() : null;
const endMonth = end ? end.getMonth() : null;
if (!end) {
return startYear === this.currentYear && startMonth === month;
if (!this.modelValue[1]) {
return this.modelValue[0].getFullYear() === this.currentYear && this.modelValue[0].getMonth() === month;
} else {
const currentDate = new Date(this.currentYear, month, 1);
const startDate = new Date(startYear, startMonth, 1);
const endDate = new Date(endYear, endMonth, 1);
const startDate = new Date(this.modelValue[0].getFullYear(), this.modelValue[0].getMonth(), 1);
const endDate = new Date(this.modelValue[1].getFullYear(), this.modelValue[1].getMonth(), 1);
return currentDate >= startDate && currentDate <= endDate;
}
Expand Down

0 comments on commit c70a9e8

Please sign in to comment.