Merge pull request #4255 from SergioCrisostomo/fix-3773
Correct month last day when changing date panel dates
This commit is contained in:
commit
147f23a50b
1 changed files with 14 additions and 5 deletions
|
@ -260,8 +260,8 @@
|
||||||
},
|
},
|
||||||
setPanelDates(leftPanelDate){
|
setPanelDates(leftPanelDate){
|
||||||
this.leftPanelDate = leftPanelDate;
|
this.leftPanelDate = leftPanelDate;
|
||||||
const rightPanelDate = new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, leftPanelDate.getDate());
|
const rightPanelDate = new Date(leftPanelDate.getFullYear(), leftPanelDate.getMonth() + 1, 1);
|
||||||
this.rightPanelDate = this.splitPanels ? new Date(Math.max(this.dates[1], rightPanelDate)) : rightPanelDate;
|
this.rightPanelDate = this.splitPanels ? new Date(Math.max(this.dates[1].getTime(), rightPanelDate.getTime())) : rightPanelDate;
|
||||||
},
|
},
|
||||||
panelLabelConfig (direction) {
|
panelLabelConfig (direction) {
|
||||||
const locale = this.t('i.locale');
|
const locale = this.t('i.locale');
|
||||||
|
@ -312,9 +312,18 @@
|
||||||
} else {
|
} else {
|
||||||
// keep the panels together
|
// keep the panels together
|
||||||
const otherPanel = panel === 'left' ? 'right' : 'left';
|
const otherPanel = panel === 'left' ? 'right' : 'left';
|
||||||
const otherCurrent = new Date(this[`${otherPanel}PanelDate`]);
|
const currentDate = this[`${otherPanel}PanelDate`];
|
||||||
otherCurrent[`set${type}`](otherCurrent[`get${type}`]() + increment);
|
const temp = new Date(currentDate);
|
||||||
this[`${otherPanel}PanelDate`] = otherCurrent;
|
|
||||||
|
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) {
|
showYearPicker (panel) {
|
||||||
|
|
Loading…
Add table
Reference in a new issue