Fix accidental date cross-overs in local cal event creation (#14587)

This commit is contained in:
Philip Allgaier 2022-12-07 09:56:21 +01:00 committed by GitHub
parent 8a5f781ca2
commit 774259224b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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
);
}