Skip to content

Commit a5b7e1b

Browse files
committed
feat(pickers): Let pickerMonth/Year know today's date
1 parent 4e910e2 commit a5b7e1b

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

src/components/PickerMonth.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,10 @@ export default {
7171
d.getMinutes(),
7272
)
7373
74+
const todayMonth = new Date(
75+
this.utils.setDate(this.utils.getNewDateObject(), 1),
76+
)
77+
7478
for (let i = 0; i < 12; i += 1) {
7579
months.push({
7680
month: this.utils.getMonthName(i, this.translation.months),
@@ -81,6 +85,7 @@ export default {
8185
this.openDate &&
8286
this.utils.compareDates(dObj, this.openDate),
8387
isSelected: this.isSelectedMonth(dObj),
88+
isToday: this.utils.compareDates(dObj, todayMonth),
8489
})
8590
this.utils.setMonth(dObj, this.utils.getMonth(dObj) + 1)
8691
}

src/components/PickerYear.vue

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,10 @@ export default {
7575
d.getHours(),
7676
d.getMinutes(),
7777
)
78+
const todayYear = new Date(
79+
this.utils.setDate(this.utils.getNewDateObject(), 1),
80+
)
81+
7882
for (let i = 0; i < this.yearRange; i += 1) {
7983
years.push({
8084
year: this.utils.getFullYear(dObj),
@@ -85,6 +89,7 @@ export default {
8589
this.openDate &&
8690
this.utils.compareDates(dObj, this.openDate),
8791
isSelected: this.isSelectedYear(dObj),
92+
isToday: this.utils.compareDates(dObj, todayYear),
8893
})
8994
this.utils.setFullYear(dObj, this.utils.getFullYear(dObj) + 1)
9095
}

0 commit comments

Comments
 (0)