From 3959a7475c835d67fa7d52e7d46d909f31e6257c Mon Sep 17 00:00:00 2001 From: Ignacio Hernandez-Ros Date: Wed, 28 Sep 2022 11:08:30 +0200 Subject: [PATCH] Bug Fix, can't create schedule on Sunday (#13876) --- src/panels/config/helpers/forms/ha-schedule-form.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/panels/config/helpers/forms/ha-schedule-form.ts b/src/panels/config/helpers/forms/ha-schedule-form.ts index a3387f9483..c28e90f8f0 100644 --- a/src/panels/config/helpers/forms/ha-schedule-form.ts +++ b/src/panels/config/helpers/forms/ha-schedule-form.ts @@ -206,6 +206,7 @@ class HaScheduleForm extends LitElement { private get _events() { const events: any[] = []; const currentDay = new Date().getDay(); + const baseDay = currentDay === 0 ? 7 : currentDay; for (const [i, day] of weekdays.entries()) { if (!this[`_${day}`].length) { @@ -214,7 +215,7 @@ class HaScheduleForm extends LitElement { this[`_${day}`].forEach((item: ScheduleDay, index: number) => { // Add 7 to 0 because we start the calendar on Monday - const distance = i - currentDay + (i === 0 ? 7 : 0); + const distance = i - baseDay + (i === 0 ? 7 : 0); const start = new Date(); start.setDate(start.getDate() + distance);