Skip to content
This repository has been archived by the owner on Jan 7, 2022. It is now read-only.

Commit

Permalink
Refactoring calendar new date
Browse files Browse the repository at this point in the history
  • Loading branch information
mariomka committed Jan 21, 2018
1 parent ccd80f5 commit d82d09c
Showing 1 changed file with 11 additions and 19 deletions.
30 changes: 11 additions & 19 deletions src/DatetimeCalendar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,21 @@ export default {
data () {
return {
newDate: DateTime.fromObject({ year: this.year, month: this.month, timeZone: 'UTC' }),
weekdays: weekdays(),
newYear: this.year,
newMonth: this.month
months: months()
}
},
computed: {
newYear () {
return this.newDate.year
},
newMonth () {
return this.newDate.month
},
monthName () {
return months()[this.newMonth - 1]
return this.months[this.newMonth - 1]
},
days () {
return monthDays(this.newYear, this.newMonth).map(day => ({
Expand All @@ -83,24 +89,10 @@ export default {
this.$emit('change', this.newYear, this.newMonth, day.number)
},
previousMonth () {
let month = this.newMonth - 1
if (month < 1) {
month = 12
this.newYear--
}
this.newMonth = month
this.newDate = this.newDate.minus({ months: 1 })
},
nextMonth () {
let month = this.newMonth + 1
if (month > 12) {
month = 1
this.newYear++
}
this.newMonth = month
this.newDate = this.newDate.plus({ months: 1 })
}
}
}
Expand Down

0 comments on commit d82d09c

Please sign in to comment.