From 382572615296a075fa41920401f89fb4422ab077 Mon Sep 17 00:00:00 2001 From: nathan Date: Fri, 7 Oct 2022 10:55:18 -0600 Subject: [PATCH] Calendar: Sidemenu calendar next/last month buttons now jump by 1 month, keeping the same day Matches toolbox arrow buttons --- calendar/js/SidemenuDate.ts | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/calendar/js/SidemenuDate.ts b/calendar/js/SidemenuDate.ts index dc1fefa321..8a387e6a30 100644 --- a/calendar/js/SidemenuDate.ts +++ b/calendar/js/SidemenuDate.ts @@ -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