mirror of
https://github.com/home-assistant/frontend.git
synced 2025-07-24 09:46:36 +00:00
Fix first day of the week locale issue with scheduler (#14529)
fixes undefined
This commit is contained in:
parent
ef3caf91f1
commit
07ad429f8c
@ -208,7 +208,10 @@ class HaScheduleForm extends LitElement {
|
||||
private get _events() {
|
||||
const events: any[] = [];
|
||||
const currentDay = new Date().getDay();
|
||||
const baseDay = currentDay === 0 ? 7 : currentDay;
|
||||
const baseDay =
|
||||
currentDay === 0 && firstWeekdayIndex(this.hass.locale) === 1
|
||||
? 7
|
||||
: currentDay;
|
||||
|
||||
for (const [i, day] of weekdays.entries()) {
|
||||
if (!this[`_${day}`].length) {
|
||||
@ -216,8 +219,11 @@ 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 - baseDay + (i === 0 ? 7 : 0);
|
||||
// Add 7 to 0 because we start the calendar on Monday, except when the locale says otherwise (firstWeekdayIndex() != 1)
|
||||
const distance =
|
||||
i -
|
||||
baseDay +
|
||||
(i === 0 && firstWeekdayIndex(this.hass.locale) === 1 ? 7 : 0);
|
||||
|
||||
const start = new Date();
|
||||
start.setDate(start.getDate() + distance);
|
||||
|
Loading…
x
Reference in New Issue
Block a user