I'm currently developing a custom calendar application using Javascript with Vue JS. One of the methods I've created is for getting the number of days in a specific month:
daysInYearMonth(y,m){
return new Date(y, m, 0).getDate()
}
When I log the result of this method for July, I correctly get 31 days. However, when I try to use this value in my calendar:
this.days = [...Array(this.daysInYearMonth(this.year,
this.month)).keys()]
}
Surprisingly, the console logs only 29 days, which is two days short. Simply adding those two days messes up the other months. You can view my code on CodePen.
Just a heads up, my team has opted not to use Moment.js and instead focus on Vue and plain JavaScript, which presents its own set of challenges.