mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-08-21 12:55:22 +00:00
add fix for sliceMultiDayEvents (#3543)
sliceMultiDayEvents occasionally gets the number of events wrong and produces too many rows Math.ceil() rounds up over 1.04 so we get an abnormal count then the calcs for the midnight loop control used different moment() functions, producing different results fixes #3542
This commit is contained in:
@@ -636,7 +636,7 @@ Module.register("calendar", {
|
||||
* if sliceMultiDayEvents is set to true, multiday events (events exceeding at least one midnight) are sliced into days,
|
||||
* otherwise, esp. in dateheaders mode it is not clear how long these events are.
|
||||
*/
|
||||
const maxCount = Math.ceil((event.endDate - 1 - moment(event.startDate, "x").endOf("day").format("x")) / ONE_DAY) + 1;
|
||||
const maxCount = Math.round((event.endDate - 1 - moment(event.startDate, "x").endOf("day").format("x")) / ONE_DAY) + 1;
|
||||
if (this.config.sliceMultiDayEvents && maxCount > 1) {
|
||||
const splitEvents = [];
|
||||
let midnight
|
||||
@@ -644,6 +644,7 @@ Module.register("calendar", {
|
||||
.clone()
|
||||
.startOf("day")
|
||||
.add(1, "day")
|
||||
.endOf("day")
|
||||
.format("x");
|
||||
let count = 1;
|
||||
while (event.endDate > midnight) {
|
||||
@@ -656,7 +657,7 @@ Module.register("calendar", {
|
||||
|
||||
event.startDate = midnight;
|
||||
count += 1;
|
||||
midnight = moment(midnight, "x").add(1, "day").format("x"); // next day
|
||||
midnight = moment(midnight, "x").add(1, "day").endOf("day").format("x"); // next day
|
||||
}
|
||||
// Last day
|
||||
event.title += ` (${count}/${maxCount})`;
|
||||
|
Reference in New Issue
Block a user