diff --git a/src/panels/calendar/dialog-calendar-event-editor.ts b/src/panels/calendar/dialog-calendar-event-editor.ts index f8cb528300..b8808ae0c2 100644 --- a/src/panels/calendar/dialog-calendar-event-editor.ts +++ b/src/panels/calendar/dialog-calendar-event-editor.ts @@ -302,7 +302,11 @@ class DialogCalendarEventEditor extends LitElement { const duration = differenceInMilliseconds(this._dtend!, this._dtstart!); this._dtstart = new Date( - ev.detail.value + "T" + this._dtstart!.toISOString().split("T")[1] + ev.detail.value + + "T" + + this._dtstart!.toLocaleTimeString("en-GB", { + timeZone: this.hass.config.time_zone, + }) ); // Prevent that the end time can be before the start time. Try to keep the @@ -326,7 +330,11 @@ class DialogCalendarEventEditor extends LitElement { private _endDateChanged(ev: CustomEvent) { this._dtend = new Date( - ev.detail.value + "T" + this._dtend!.toISOString().split("T")[1] + ev.detail.value + + "T" + + this._dtend!.toLocaleTimeString("en-GB", { + timeZone: this.hass.config.time_zone, + }) ); } @@ -335,7 +343,11 @@ class DialogCalendarEventEditor extends LitElement { const duration = differenceInMilliseconds(this._dtend!, this._dtstart!); this._dtstart = new Date( - this._dtstart!.toISOString().split("T")[0] + "T" + ev.detail.value + this._dtstart!.toLocaleDateString("en-CA", { + timeZone: this.hass.config.time_zone, + }) + + "T" + + ev.detail.value ); // Prevent that the end time can be before the start time. Try to keep the @@ -357,7 +369,11 @@ class DialogCalendarEventEditor extends LitElement { private _endTimeChanged(ev: CustomEvent) { this._dtend = new Date( - this._dtend!.toISOString().split("T")[0] + "T" + ev.detail.value + this._dtend!.toLocaleDateString("en-CA", { + timeZone: this.hass.config.time_zone, + }) + + "T" + + ev.detail.value ); }