Skip to content

Commit fd929cf

Browse files
authored
Merge pull request #573 from totaldebug/571-events_missing_single_day
fix: when set to single day, events are not shown
2 parents f6bd09b + 524c72d commit fd929cf

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

dist/atomic-calendar-revive.js

Lines changed: 4 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "atomic-calendar-revive",
3-
"version": "7.0.0-b1",
3+
"version": "7.0.0-b2",
44
"editor_version": "2.0.0",
55
"description": "Calendar Card for Home Assistant",
66
"main": "atomic-calendar-revive.js",

src/lib/event.func.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,12 @@ function buildCalendar(config: atomicCardConfig, selectedMonth) {
114114
export async function getEventMode(config: atomicCardConfig, hass) {
115115

116116
const daysToShow = config.maxDaysToShow! == 0 ? config.maxDaysToShow! : config.maxDaysToShow! - 1;
117-
const today = dayjs().startOf('day');
117+
const today = dayjs();
118118
const start = today
119+
.startOf('day')
119120
.add(config.startDaysAhead!, 'day');
120121
const end = today
122+
.endOf('day')
121123
.add(daysToShow + config.startDaysAhead!, 'day');
122124
const getEvents = await getAllEvents(start, end, config, hass);
123125
return getEvents;
@@ -154,14 +156,16 @@ export async function getCalendarMode(config: atomicCardConfig, hass, selectedMo
154156
export async function getAllEvents(start: dayjs.Dayjs, end: dayjs.Dayjs, config: atomicCardConfig, hass) {
155157

156158
// format times correctly
157-
const today = dayjs().startOf('day');
159+
const today = dayjs();
158160
const dateFormat = 'YYYY-MM-DDTHH:mm:ss';
159161
const timeOffset = -dayjs().utcOffset();
160162

161163
const startTime = start
164+
.startOf('day')
162165
.add(timeOffset, 'minutes')
163166
.format(dateFormat);
164167
const endTime = end
168+
.endOf('day')
165169
.add(timeOffset, 'minutes')
166170
.format(dateFormat);
167171

@@ -176,7 +180,7 @@ export async function getAllEvents(start: dayjs.Dayjs, end: dayjs.Dayjs, config:
176180
const calendarEntity = (entity && entity.entity) || entity;
177181

178182
// get correct end date if maxDaysToShow is set
179-
const entityEnd = typeof entity.maxDaysToShow != 'undefined' ? today
183+
const entityEnd = typeof entity.maxDaysToShow != 'undefined' ? today.endOf('day')
180184
.add(entity.maxDaysToShow! - 1 + config.startDaysAhead!, 'day')
181185
.add(timeOffset, 'minutes').format(dateFormat) : endTime;
182186

0 commit comments

Comments
 (0)