diff --git a/src/index.ts b/src/index.ts index 9e3185de..73995b51 100644 --- a/src/index.ts +++ b/src/index.ts @@ -303,7 +303,7 @@ export class AtomicCalendarRevive extends LitElement { /** * If there are no events, put some text in */ - if (days.length === 0 && this._config.maxDaysToShow == 1) { + if (days.length === 0 && (this._config.maxDaysToShow == 1 || this._config.maxDaysToShow == 0)) { this.content = this._config.noEventText; return; } else if (days.length === 0) { diff --git a/src/lib/event.func.ts b/src/lib/event.func.ts index e2a6e3e6..104b26ff 100644 --- a/src/lib/event.func.ts +++ b/src/lib/event.func.ts @@ -148,7 +148,6 @@ export async function getAllEvents(start: dayjs.Dayjs, end: dayjs.Dayjs, config: const dateFormat = 'YYYY-MM-DDTHH:mm:ss'; const startTime = start.startOf('day').format(dateFormat); - const endTime = end.endOf('day').format(dateFormat); // for each calendar entity get all events // each entity may be a string of entity id or @@ -160,6 +159,11 @@ export async function getAllEvents(start: dayjs.Dayjs, end: dayjs.Dayjs, config: config.entities.map((entity) => { const calendarEntity = (entity && entity.entity) || entity; + const endTime = entity.maxDaysToShow! !== undefined ? dayjs() + .add(entity.maxDaysToShow! - 1 + config.startDaysAhead!, 'day') + .endOf('day') + .format('YYYY-MM-DDTHH:mm:ss') : end.endOf('day').format(dateFormat);; + const url: string = `calendars/${entity.entity}?start=${startTime}Z&end=${endTime}Z`; // make all requests at the same time