Commit 3aeb2bc692a12f273595bc700346a8771e3a9b0d
1 parent
28a0f8b0
Correct month last day
Showing
1 changed file
with
12 additions
and
3 deletions
Show diff stats
src/components/date-picker/panel/Date/date-range.vue
... | ... | @@ -312,9 +312,18 @@ |
312 | 312 | } else { |
313 | 313 | // keep the panels together |
314 | 314 | const otherPanel = panel === 'left' ? 'right' : 'left'; |
315 | - const otherCurrent = new Date(this[`${otherPanel}PanelDate`]); | |
316 | - otherCurrent[`set${type}`](otherCurrent[`get${type}`]() + increment); | |
317 | - this[`${otherPanel}PanelDate`] = otherCurrent; | |
315 | + const currentDate = this[`${otherPanel}PanelDate`]; | |
316 | + const temp = new Date(currentDate); | |
317 | + | |
318 | + if (type === 'Month') { | |
319 | + const nextMonthLastDate = new Date( | |
320 | + temp.getFullYear(), temp.getMonth() + increment + 1, 0 | |
321 | + ).getDate(); | |
322 | + temp.setDate(Math.min(nextMonthLastDate, temp.getDate())); | |
323 | + } | |
324 | + | |
325 | + temp[`set${type}`](temp[`get${type}`]() + increment); | |
326 | + this[`${otherPanel}PanelDate`] = temp; | |
318 | 327 | } |
319 | 328 | }, |
320 | 329 | showYearPicker (panel) { | ... | ... |