Calendar: Sidemenu calendar next/last month buttons now jump by 1 month, keeping the same day

Matches toolbox arrow buttons
This commit is contained in:
nathan 2022-10-07 10:55:18 -06:00
parent 38d5cd627f
commit 3825726152

View File

@ -296,7 +296,12 @@ export class SidemenuDate extends Et2Date
*/
protected _handleHeaderChange()
{
let temp_date = new Date("" + this._instance.currentYear + "-" + (this._instance.currentMonth + 1) + "-01");
const maxDays = new Date(this._instance.currentYear, this._instance.currentMonth + 1, 0).getDate();
let temp_date = new Date("" + this._instance.currentYear + "-" +
(this._instance.currentMonth + 1) + "-" +
("" + Math.min(maxDays, new Date(this.value).getUTCDate())).padStart(2, "0")
);
temp_date.setUTCMinutes(temp_date.getUTCMinutes() + temp_date.getTimezoneOffset());
// Go directly