Skip to content

Commit

Permalink
Fix year/month select on the datepicker
Browse files Browse the repository at this point in the history
Signed-off-by: John Molakvoæ (skjnldsv) <skjnldsv@protonmail.com>
  • Loading branch information
skjnldsv committed Aug 29, 2019
1 parent eea76b6 commit 5164c3f
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions src/components/DatetimePicker/DatetimePicker.vue
Original file line number Diff line number Diff line change
Expand Up @@ -76,22 +76,24 @@ export default {
methods: {
handleSelectYear(year) {
if (this.value) {
const value = this.$refs.datepicker.currentValue
if (value) {
try {
const value = new Date(new Date(this.value).setFullYear(year))
this.$refs.datepicker.selectDate(value)
const date = new Date(new Date(value).setFullYear(year))
this.$refs.datepicker.selectDate(date)
} catch (error) {
console.error('Invalid value', this.value, year)
console.error('Invalid value', value, year)
}
}
},
handleSelectMonth(month) {
if (this.value) {
const value = this.$refs.datepicker.currentValue
if (value) {
try {
const value = new Date(new Date(this.value).setMonth(month))
this.$refs.datepicker.selectDate(value)
const date = new Date(new Date(value).setMonth(month))
this.$refs.datepicker.selectDate(date)
} catch (error) {
console.error('Invalid value', this.value, month)
console.error('Invalid value', value, month)
}
}
}
Expand Down

0 comments on commit 5164c3f

Please sign in to comment.