Skip to content

Commit

Permalink
Merge pull request #548 from nextcloud/fix/datepicker/year-month-select
Browse files Browse the repository at this point in the history
Fix year/month select on the datepicker
  • Loading branch information
skjnldsv authored Aug 29, 2019
2 parents e2e9d8d + 5164c3f commit 3996f13
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 3996f13

Please sign in to comment.