From 3aeb2bc692a12f273595bc700346a8771e3a9b0d Mon Sep 17 00:00:00 2001 From: SergioCrisostomo Date: Fri, 10 Aug 2018 14:29:00 +0200 Subject: [PATCH 1/2] Correct month last day --- .../date-picker/panel/Date/date-range.vue | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/components/date-picker/panel/Date/date-range.vue b/src/components/date-picker/panel/Date/date-range.vue index 42fabd60..ae0925ad 100644 --- a/src/components/date-picker/panel/Date/date-range.vue +++ b/src/components/date-picker/panel/Date/date-range.vue @@ -312,9 +312,18 @@ } else { // keep the panels together const otherPanel = panel === 'left' ? 'right' : 'left'; - const otherCurrent = new Date(this[`${otherPanel}PanelDate`]); - otherCurrent[`set${type}`](otherCurrent[`get${type}`]() + increment); - this[`${otherPanel}PanelDate`] = otherCurrent; + const currentDate = this[`${otherPanel}PanelDate`]; + const temp = new Date(currentDate); + + if (type === 'Month') { + const nextMonthLastDate = new Date( + temp.getFullYear(), temp.getMonth() + increment + 1, 0 + ).getDate(); + temp.setDate(Math.min(nextMonthLastDate, temp.getDate())); + } + + temp[`set${type}`](temp[`get${type}`]() + increment); + this[`${otherPanel}PanelDate`] = temp; } }, showYearPicker (panel) { From 226b084cd5545fc52eea3ab11e477722c455825f Mon Sep 17 00:00:00 2001 From: SergioCrisostomo Date: Fri, 24 Aug 2018 11:11:19 +0200 Subject: [PATCH 2/2] Use first of month and not other panels date since in cases where prev month date > next month date it will jump one more month ahead --- src/components/date-picker/panel/Date/date-range.vue | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/date-picker/panel/Date/date-range.vue b/src/components/date-picker/panel/Date/date-range.vue index ae0925ad..153e8ebd 100644 --- a/src/components/date-picker/panel/Date/date-range.vue +++ b/src/components/date-picker/panel/Date/date-range.vue @@ -260,8 +260,8 @@ }, setPanelDates(leftPanelDate){ this.leftPanelDate = leftPanelDate; - const rightPanelDate = new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, leftPanelDate.getDate()); - this.rightPanelDate = this.splitPanels ? new Date(Math.max(this.dates[1], rightPanelDate)) : rightPanelDate; + const rightPanelDate = new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, 1); + this.rightPanelDate = this.splitPanels ? new Date(Math.max(this.dates[1].getTime(), rightPanelDate.getTime())) : rightPanelDate; }, panelLabelConfig (direction) { const locale = this.t('i.locale');