Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixcaldates2 fix calendar module date processing, using [email protected] #3587

Merged
merged 45 commits into from
Dec 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
77a3e80
fix dates with [email protected]
sdetweil Oct 17, 2024
491970c
package.json to [email protected]
sdetweil Oct 17, 2024
b046b00
update to node-ical 0.19.0
sdetweil Oct 17, 2024
40bfc53
add CHANGELOG update
sdetweil Oct 17, 2024
b42bdb0
fix for notification from other modules
sdetweil Oct 17, 2024
152312f
remove logLevel config from chicago tz test config.js
sdetweil Oct 17, 2024
f6d14aa
fix chicago test duration to cover ics event time
sdetweil Oct 17, 2024
ebe90fd
Merge branch 'develop' into fixcaldates2
sdetweil Oct 19, 2024
9bb089c
fix testcases add/ipwhitelist and chaicago in wrong place
sdetweil Oct 19, 2024
dbc2fe8
fix and add another testcase for end of day roll over tested from dif…
sdetweil Oct 19, 2024
626c5e7
use updated node-ical add new testcases to be used
sdetweil Oct 20, 2024
ebca307
add testcases for edge conditions
sdetweil Oct 21, 2024
b9eddc0
fix for 3267 and event with both exdate and recurrence changes
sdetweil Oct 21, 2024
5309d4b
use updated node-ical, not yet on npm store
sdetweil Oct 21, 2024
f6bf0c1
cleanup up utils, remove dead old code, add header to new functions
sdetweil Oct 21, 2024
2402fff
fix on testcase, add another for start one tz, end another
sdetweil Oct 22, 2024
e68a5f6
add support for end date display for fullday events, showEnd:true, da…
sdetweil Oct 23, 2024
5265ba5
add run date/time to testcase file as helper failed to do that
sdetweil Oct 23, 2024
2763f75
Revert "add run date/time to testcase file as helper failed to do tha…
sdetweil Oct 23, 2024
d10855a
add run date/time to testcase js file as helper failed to do that
sdetweil Oct 23, 2024
f99bb9f
Merge branch 'develop' into fixcaldates2
sdetweil Oct 23, 2024
5a133e3
sync changelog
sdetweil Oct 25, 2024
a4fb29d
fix testcases for showEndsOnlyWithDuration, add showEnd:true support …
sdetweil Oct 25, 2024
094c199
fix showEndsOnlyWithDuration, only applies to full day events
sdetweil Oct 26, 2024
aff20d0
fix changelog
sdetweil Nov 4, 2024
9ac5ff2
upgrade node-ical to latest
sdetweil Nov 4, 2024
8b7296a
Merge branch 'develop' into fixcaldates2
sdetweil Nov 4, 2024
bab9b71
sync to develop
sdetweil Nov 13, 2024
d973ed9
fix lint issues
sdetweil Nov 13, 2024
d6835d6
force fail on e2e calendar tests to see content, determine what failed
sdetweil Nov 13, 2024
2956f3a
fix multi-cal and maxEntries by cal sorting and slicing
sdetweil Nov 13, 2024
768080c
display raw time in events
sdetweil Nov 13, 2024
ff80356
cleanup debug and limits per calendar
sdetweil Nov 14, 2024
916bb37
fix one innerText add corrected e2e testcase
sdetweil Nov 14, 2024
b8c14d1
Merge branch 'develop' into fixcaldates2
sdetweil Nov 14, 2024
9be5535
fix lint error correction done wrong
sdetweil Nov 15, 2024
98ed468
add compliments_file tests to e2e, fix module for interval timer stil…
sdetweil Nov 15, 2024
070a135
fix sdate shown for in progress fullday multi-day events
sdetweil Nov 20, 2024
8050a4f
Merge branch 'develop' into fixcaldates2
sdetweil Nov 20, 2024
97880df
sync changelog
sdetweil Dec 4, 2024
e43be28
fix review changes, mostly remove dead comments
sdetweil Dec 5, 2024
f9239a9
restore changed default on dateFormat
sdetweil Dec 5, 2024
95a81d1
Update show-duplicates-in-calendar.js
sdetweil Dec 6, 2024
bf1b1b3
Update calendar_spec.js
sdetweil Dec 6, 2024
c9576ea
Merge branch 'develop' into fixcaldates2
rejas Dec 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ _This release is scheduled to be released on 2025-01-01._
- [linter] Re-add `eslint-plugin-import`now that it supports ESLint v9 (#3586)
- [linter] Re-activate `eslint-plugin-package-json` to lint `package.json`
- [core] Add export on animation names
- [calendar] - added ability to display end date for full date events, where end is not same day (showEnd=true)

### Removed

Expand All @@ -38,12 +39,16 @@ _This release is scheduled to be released on 2025-01-01._

- [updatenotification] Fix pm2 using detection when pm2 script is inside or outside MagicMirror root folder (#3576) (#3605) (#3626) (#3628)
- [core] Fix loading node_helper of modules: avoid black screen, display errors and continue loading with next module (#3578)
- [weather] Changed default value for weatherEndpoint of provider openweathermap to "/onecall" (#3574)
- [tests] Fix electron tests with mock dates, the mock on server side was missing (#3597)
- [tests] Fix test cases with hard coded Date.now (#3597)
- [weather] changed default value for weatherEndpoint of provider openweathermap to "/onecall" (#3574)
sdetweil marked this conversation as resolved.
Show resolved Hide resolved
- [tests] fix electron tests with mock dates, the mock on server side was missing (#3597)
- [tests] fix testcases with hard coded Date.now (#3597)
- [core] Fix missing `basePath` where `location.host` is used (#3613)
- [compliments] croner library changed filenames used in latest version (#3624)
- [linter] Fix ESLint ignore pattern which caused that default modules not to be linted (#3632)
- [calendar] - update to resolve issues #3098 #3144 #3351 #3422 #3443 #3467 #3537 related to timezone changes
- [calendar] - fixes #3267 (styles array), also fixes event with both exdate AND recurrence(and testcase)
- [calendar] - fix showEndsOnlyWithDuration not working, #3598, applies ONLY to full day events
- [calendar] - fix showEnd for Full Day events #3602
- [tests] Suppress "module is not defined" in e2e tests

## [2.29.0] - 2024-10-01
Expand Down
55 changes: 38 additions & 17 deletions modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,12 +168,17 @@ Module.register("calendar", {

this.selfUpdate();
},
notificationReceived (notification, payload, sender) {

// Override socket notification handler.
socketNotificationReceived (notification, payload) {
if (notification === "FETCH_CALENDAR") {
this.sendSocketNotification(notification, { url: payload.url, id: this.identifier });
if (this.hasCalendarURL(payload.url)) {
this.sendSocketNotification(notification, { url: payload.url, id: this.identifier });
}
}
},

// Override socket notification handler.
socketNotificationReceived (notification, payload) {

if (this.identifier !== payload.id) {
return;
Expand Down Expand Up @@ -417,18 +422,26 @@ Module.register("calendar", {
timeWrapper.innerHTML = CalendarUtils.capFirst(moment(event.startDate, "x").format(this.config.dateFormat));
// Add end time if showEnd
if (this.config.showEnd) {
if (this.config.showEndsOnlyWithDuration && event.startDate === event.endDate) {
// no duration here, don't display end
} else {
// and has a duation
if (event.startDate !== event.endDate) {
timeWrapper.innerHTML += "-";
timeWrapper.innerHTML += CalendarUtils.capFirst(moment(event.endDate, "x").format(this.config.dateEndFormat));
}
}

// For full day events we use the fullDayEventDateFormat
if (event.fullDayEvent) {
//subtract one second so that fullDayEvents end at 23:59:59, and not at 0:00:00 one the next day
event.endDate -= ONE_SECOND;
timeWrapper.innerHTML = CalendarUtils.capFirst(moment(event.startDate, "x").format(this.config.fullDayEventDateFormat));
// only show end if requested and allowed and the dates are different
if (this.config.showEnd && !this.config.showEndsOnlyWithDuration && moment(event.startDate, "x").format("YYYYMMDD") !== moment(event.endDate, "x").format("YYYYMMDD")) {
timeWrapper.innerHTML += "-";
timeWrapper.innerHTML += CalendarUtils.capFirst(moment(event.endDate, "x").format(this.config.fullDayEventDateFormat));
} else
if ((moment(event.startDate, "x").format("YYYYMMDD") !== moment(event.endDate, "x").format("YYYYMMDD")) && (moment(event.startDate, "x") < moment(now, "x"))) {
timeWrapper.innerHTML = CalendarUtils.capFirst(moment(now, "x").format(this.config.fullDayEventDateFormat));
}
} else if (this.config.getRelative > 0 && event.startDate < now) {
// Ongoing and getRelative is set
timeWrapper.innerHTML = CalendarUtils.capFirst(
Expand Down Expand Up @@ -460,16 +473,18 @@ Module.register("calendar", {
if (event.startDate >= now || (event.fullDayEvent && this.eventEndingWithinNextFullTimeUnit(event, ONE_DAY))) {
// Use relative time
if (!this.config.hideTime && !event.fullDayEvent) {
timeWrapper.innerHTML = CalendarUtils.capFirst(moment(event.startDate, "x").calendar(null, { sameElse: this.config.dateFormat }));
Log.debug("event not hidden and not fullday");
timeWrapper.innerHTML = `${CalendarUtils.capFirst(moment(event.startDate, "x").calendar(null, { sameElse: this.config.dateFormat }))}`;
} else {
timeWrapper.innerHTML = CalendarUtils.capFirst(
Log.debug("event full day or hidden");
timeWrapper.innerHTML = `${CalendarUtils.capFirst(
moment(event.startDate, "x").calendar(null, {
sameDay: this.config.showTimeToday ? "LT" : `[${this.translate("TODAY")}]`,
nextDay: `[${this.translate("TOMORROW")}]`,
nextWeek: "dddd",
sameElse: event.fullDayEvent ? this.config.fullDayEventDateFormat : this.config.dateFormat
})
);
)}`;
}
if (event.fullDayEvent) {
// Full days events within the next two days
Expand All @@ -488,9 +503,11 @@ Module.register("calendar", {
timeWrapper.innerHTML = CalendarUtils.capFirst(this.translate("DAYAFTERTOMORROW"));
}
}
Log.info("event fullday");
} else if (event.startDate - now < this.config.getRelative * ONE_HOUR) {
Log.info("not full day but within getrelative size");
// If event is within getRelative hours, display 'in xxx' time format or moment.fromNow()
timeWrapper.innerHTML = CalendarUtils.capFirst(moment(event.startDate, "x").fromNow());
timeWrapper.innerHTML = `${CalendarUtils.capFirst(moment(event.startDate, "x").fromNow())}`;
}
} else {
// Ongoing event
Expand Down Expand Up @@ -603,6 +620,7 @@ Module.register("calendar", {
const calendar = this.calendarData[calendarUrl];
let remainingEntries = this.maximumEntriesForUrl(calendarUrl);
let maxPastDaysCompare = now - this.maximumPastDaysForUrl(calendarUrl) * ONE_DAY;
let by_url_calevents = [];
for (const e in calendar) {
const event = JSON.parse(JSON.stringify(calendar[e])); // clone object

Expand All @@ -620,9 +638,6 @@ Module.register("calendar", {
if (this.config.hideDuplicates && this.listContainsEvent(events, event)) {
continue;
}
if (--remainingEntries < 0) {
break;
}
}

event.url = calendarUrl;
Expand Down Expand Up @@ -667,15 +682,21 @@ Module.register("calendar", {

for (let splitEvent of splitEvents) {
if (splitEvent.endDate > now && splitEvent.endDate <= future) {
events.push(splitEvent);
by_url_calevents.push(splitEvent);
}
}
} else {
events.push(event);
by_url_calevents.push(event);
}
}
by_url_calevents.sort(function (a, b) {
return a.startDate - b.startDate;
});
Log.debug(`pushing ${by_url_calevents.length} events to total with room for ${remainingEntries}`);
events = events.concat(by_url_calevents.slice(0, remainingEntries));
Log.debug(`events for calendar=${events.length}`);
}

Log.info(`sorting events count=${events.length}`);
events.sort(function (a, b) {
return a.startDate - b.startDate;
});
Expand Down Expand Up @@ -715,7 +736,7 @@ Module.register("calendar", {
}
events = newEvents;
}

Log.info(`slicing events total maxcount=${this.config.maximumEntries}`);
return events.slice(0, this.config.maximumEntries);
},

Expand Down
2 changes: 1 addition & 1 deletion modules/default/calendar/calendarfetcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const CalendarFetcher = function (url, reloadInterval, excludedEvents, maximumEn

try {
data = ical.parseICS(responseData);
Log.debug(`parsed data=${JSON.stringify(data)}`);
Log.debug(`parsed data=${JSON.stringify(data, null, 2)}`);
events = CalendarFetcherUtils.filterEvents(data, {
excludedEvents,
includePastEvents,
Expand Down
Loading
Loading