Skip to content

Commit e368fd6

Browse files
authored
fix(calendar): sliced multi-day events start at 00:00, not 23:59 (#4208)
1 parent f5ef002 commit e368fd6

4 files changed

Lines changed: 57 additions & 1 deletion

File tree

defaultmodules/calendar/calendar.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ Module.register("calendar", {
531531
thisEvent.title += ` (${count}/${maxCount})`;
532532
splitEvents.push(thisEvent);
533533

534-
event.startDate = midnight.format("x");
534+
event.startDate = midnight.clone().startOf("day").format("x"); // start next slice at 00:00, not 23:59
535535
count += 1;
536536
midnight = midnight.clone().add(1, "day").endOf("day"); // next day
537537
}

tests/configs/modules/calendar/calendarShowEndConfigs.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,32 @@ const calendarShowEndConfigs = {
347347
}
348348
}
349349
]
350+
},
351+
slice_multiday_timed_start_midnight: {
352+
address: "0.0.0.0",
353+
ipWhitelist: [],
354+
timeFormat: 24,
355+
modules: [
356+
{
357+
module: "calendar",
358+
position: "bottom_bar",
359+
config: {
360+
fade: false,
361+
urgency: 0,
362+
dateFormat: "Do.MMM, HH:mm",
363+
fullDayEventDateFormat: "Do.MMM",
364+
timeFormat: "absolute",
365+
getRelative: 0,
366+
sliceMultiDayEvents: true,
367+
calendars: [
368+
{
369+
maximumEntries: 100,
370+
url: "http://localhost:8080/tests/mocks/calendar_test_slice_multiday_timed.ics"
371+
}
372+
]
373+
}
374+
}
375+
]
350376
}
351377
};
352378

tests/electron/modules/calendar_spec.js

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,20 @@ describe("Calendar module", () => {
181181
});
182182
});
183183

184+
describe("sliceMultiDayEvents slice start time", () => {
185+
it("sliced sub-events start at 00:00, not 23:59", async () => {
186+
// Timed event Fri 25 Oct 12:00 -> Mon 28 Oct 08:00 (UTC) is sliced across
187+
// several midnights. Every slice after the first must start at 00:00 of its
188+
// day. Regression for the bug where they started at 23:59 instead.
189+
await startCalendarShowEndScenario("slice_multiday_timed_start_midnight", "25 Oct 2024 06:00:00 GMT", "GMT");
190+
const firstTimeCell = global.page.locator(".calendar .event .time").locator(`nth=${first}`);
191+
await firstTimeCell.waitFor({ state: "visible" });
192+
const times = await global.page.locator(".calendar .event .time").allTextContents();
193+
expect(times.some((time) => time.includes("00:00"))).toBe(true);
194+
expect(times.every((time) => !time.includes("23:59"))).toBe(true);
195+
});
196+
});
197+
184198
describe("germany timezone", () => {
185199
it("Issue #unknown fullday timezone East of UTC edge", async () => {
186200
await helpers.startApplication("tests/configs/modules/calendar/germany_at_end_of_day_repeating.js", "01 Oct 2024 10:38:00 GMT+02:00", [], "Europe/Berlin");
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
BEGIN:VCALENDAR
2+
VERSION:2.0
3+
PRODID:-//MagicMirror//slice regression//EN
4+
CALSCALE:GREGORIAN
5+
METHOD:PUBLISH
6+
BEGIN:VEVENT
7+
DTSTART:20241025T120000Z
8+
DTEND:20241028T080000Z
9+
DTSTAMP:20241024T153358Z
10+
UID:slice-midnight-regression@magicmirror.test
11+
SEQUENCE:0
12+
STATUS:CONFIRMED
13+
SUMMARY:Timed multi-day slice
14+
TRANSP:OPAQUE
15+
END:VEVENT
16+
END:VCALENDAR

0 commit comments

Comments
 (0)