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

Better fixes for #3291 and the underlying exdate issues #3342

Merged
merged 15 commits into from
Jan 27, 2024
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ _This release is scheduled to be released on 2024-04-01._

- Unneeded file headers (#3358)

## [2.27.0] - UNRELEASED

### Fixed

- Worked around several issues in the RRULE library that were causing deleted calender events to still show, some
initial and recurring events to not show, and some event times to be off an hour. (#3291)

## [2.26.0] - 01-01-2024

Thanks to: @bnitkin, @bugsounet, @dependabot, @jkriegshauser, @kaennchenstruggle, @KristjanESPERANTO and @Ybbet.
Expand Down
14 changes: 11 additions & 3 deletions modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ Module.register("calendar", {
hideDuplicates: true,
showTimeToday: false,
colored: false,
forceUseCurrentTime: false,
tableClass: "small",
calendars: [
{
Expand Down Expand Up @@ -567,9 +568,16 @@ Module.register("calendar", {
const ONE_HOUR = ONE_MINUTE * 60;
const ONE_DAY = ONE_HOUR * 24;

const now = new Date();
const today = moment().startOf("day");
const future = moment().startOf("day").add(this.config.maximumNumberOfDays, "days").toDate();
let now, today, future;
if (this.config.forceUseCurrentTime || this.defaults.forceUseCurrentTime) {
now = new Date();
today = moment().startOf("day");
future = moment().startOf("day").add(this.config.maximumNumberOfDays, "days").toDate();
} else {
now = new Date(Date.now()); // Can use overridden time
today = moment(now).startOf("day");
future = moment(now).startOf("day").add(this.config.maximumNumberOfDays, "days").toDate();
}
let events = [];

for (const calendarUrl in this.calendarData) {
Expand Down
253 changes: 110 additions & 143 deletions modules/default/calendar/calendarfetcherutils.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions tests/configs/modules/calendar/custom.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ let config = {
position: "bottom_bar",
config: {
customEvents: [{ keyword: "CustomEvent", symbol: "dice", eventClass: "undo" }],
forceUseCurrentTime: true,
calendars: [
{
maximumEntries: 5,
Expand Down
31 changes: 0 additions & 31 deletions tests/configs/modules/calendar/exdate.js

This file was deleted.

37 changes: 37 additions & 0 deletions tests/configs/modules/calendar/exdate_la_at_midnight_dst.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* MagicMirror² Test calendar exdate
*
* By jkriegshauser
* MIT Licensed.
*
* See issue #3250
* See tests/electron/modules/calendar_spec.js
*/
let config = {
timeFormat: 12,

modules: [
{
module: "calendar",
position: "bottom_bar",
config: {
maximumEntries: 100,
calendars: [
{
maximumEntries: 100,
maximumNumberOfDays: 28, // 4 weeks, 2 of which are skipped
url: "http://localhost:8080/tests/mocks/exdate_la_at_midnight_dst.ics"
}
]
}
}
]
};

Date.now = () => {
return new Date("19 Oct 2023 12:30:00 GMT-07:00").valueOf();
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}
37 changes: 37 additions & 0 deletions tests/configs/modules/calendar/exdate_la_at_midnight_std.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* MagicMirror² Test calendar exdate
*
* By jkriegshauser
* MIT Licensed.
*
* See issue #3250
* See tests/electron/modules/calendar_spec.js
*/
let config = {
timeFormat: 12,

modules: [
{
module: "calendar",
position: "bottom_bar",
config: {
maximumEntries: 100,
calendars: [
{
maximumEntries: 100,
maximumNumberOfDays: 28, // 4 weeks, 2 of which are skipped
url: "http://localhost:8080/tests/mocks/exdate_la_at_midnight_std.ics"
}
]
}
}
]
};

Date.now = () => {
return new Date("19 Oct 2023 12:30:00 GMT-07:00").valueOf();
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}
37 changes: 37 additions & 0 deletions tests/configs/modules/calendar/exdate_la_before_midnight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* MagicMirror² Test calendar exdate
*
* By jkriegshauser
* MIT Licensed.
*
* See issue #3250
* See tests/electron/modules/calendar_spec.js
*/
let config = {
timeFormat: 12,

modules: [
{
module: "calendar",
position: "bottom_bar",
config: {
maximumEntries: 100,
calendars: [
{
maximumEntries: 100,
maximumNumberOfDays: 28, // 4 weeks, 2 of which are skipped
url: "http://localhost:8080/tests/mocks/exdate_la_before_midnight.ics"
}
]
}
}
]
};

Date.now = () => {
return new Date("19 Oct 2023 12:30:00 GMT-07:00").valueOf();
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}
37 changes: 37 additions & 0 deletions tests/configs/modules/calendar/exdate_syd_at_midnight_dst.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* MagicMirror² Test calendar exdate
*
* By jkriegshauser
* MIT Licensed.
*
* See issue #3250
* See tests/electron/modules/calendar_spec.js
*/
let config = {
timeFormat: 12,

modules: [
{
module: "calendar",
position: "bottom_bar",
config: {
maximumEntries: 100,
calendars: [
{
maximumEntries: 100,
maximumNumberOfDays: 28, // 4 weeks, 2 of which are skipped
url: "http://localhost:8080/tests/mocks/exdate_syd_at_midnight_dst.ics"
}
]
}
}
]
};

Date.now = () => {
return new Date("14 Sep 2023 12:30:00 GMT+10:00").valueOf();
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}
37 changes: 37 additions & 0 deletions tests/configs/modules/calendar/exdate_syd_at_midnight_std.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* MagicMirror² Test calendar exdate
*
* By jkriegshauser
* MIT Licensed.
*
* See issue #3250
* See tests/electron/modules/calendar_spec.js
*/
let config = {
timeFormat: 12,

modules: [
{
module: "calendar",
position: "bottom_bar",
config: {
maximumEntries: 100,
calendars: [
{
maximumEntries: 100,
maximumNumberOfDays: 28, // 4 weeks, 2 of which are skipped
url: "http://localhost:8080/tests/mocks/exdate_syd_at_midnight_std.ics"
}
]
}
}
]
};

Date.now = () => {
return new Date("14 Sep 2023 12:30:00 GMT+10:00").valueOf();
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}
37 changes: 37 additions & 0 deletions tests/configs/modules/calendar/exdate_syd_before_midnight.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/* MagicMirror² Test calendar exdate
*
* By jkriegshauser
* MIT Licensed.
*
* See issue #3250
* See tests/electron/modules/calendar_spec.js
*/
let config = {
timeFormat: 12,

modules: [
{
module: "calendar",
position: "bottom_bar",
config: {
maximumEntries: 100,
calendars: [
{
maximumEntries: 100,
maximumNumberOfDays: 28, // 4 weeks, 2 of which are skipped
url: "http://localhost:8080/tests/mocks/exdate_syd_before_midnight.ics"
}
]
}
}
]
};

Date.now = () => {
return new Date("14 Sep 2023 12:30:00 GMT+10:00").valueOf();
};

/*************** DO NOT EDIT THE LINE BELOW ***************/
if (typeof module !== "undefined") {
module.exports = config;
}
6 changes: 3 additions & 3 deletions tests/electron/helpers/global-setup.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@
// https://www.anycodings.com/1questions/958135/can-i-set-the-date-for-playwright-browser
const { _electron: electron } = require("playwright");

exports.startApplication = async (configFilename, systemDate = null, electronParams = ["js/electron.js"]) => {
exports.startApplication = async (configFilename, systemDate = null, electronParams = ["js/electron.js"], timezone = "GMT") => {
global.electronApp = null;
global.page = null;
process.env.MM_CONFIG_FILE = configFilename;
process.env.TZ = "GMT";
process.env.TZ = timezone;
global.electronApp = await electron.launch({ args: electronParams });

await global.electronApp.firstWindow();
Expand All @@ -20,7 +20,7 @@ exports.startApplication = async (configFilename, systemDate = null, electronPar
if (systemDate) {
await global.page.evaluate((systemDate) => {
Date.now = () => {
return new Date(systemDate);
return new Date(systemDate).valueOf();
};
}, systemDate);
}
Expand Down
Loading
Loading