mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-07-03 14:26:07 +00:00
Fix for #207
This commit is contained in:
parent
fd500ac411
commit
fa38ad3a74
@ -43,8 +43,6 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
var today = moment().startOf("day").toDate();
|
var today = moment().startOf("day").toDate();
|
||||||
var future = moment().startOf("day").add(maximumNumberOfDays, "days").subtract(1,"seconds").toDate(); // Subtract 1 second so that events that start on the middle of the night will not repeat.
|
var future = moment().startOf("day").add(maximumNumberOfDays, "days").subtract(1,"seconds").toDate(); // Subtract 1 second so that events that start on the middle of the night will not repeat.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// FIXME:
|
// FIXME:
|
||||||
// Ugly fix to solve the facebook birthday issue.
|
// Ugly fix to solve the facebook birthday issue.
|
||||||
// Otherwise, the recurring events only show the birthday for next year.
|
// Otherwise, the recurring events only show the birthday for next year.
|
||||||
@ -57,6 +55,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
|
|
||||||
if (event.type === "VEVENT") {
|
if (event.type === "VEVENT") {
|
||||||
|
|
||||||
|
//console.log(event);
|
||||||
|
|
||||||
var startDate = (event.start.length === 8) ? moment(event.start, "YYYYMMDD") : moment(new Date(event.start));
|
var startDate = (event.start.length === 8) ? moment(event.start, "YYYYMMDD") : moment(new Date(event.start));
|
||||||
var endDate;
|
var endDate;
|
||||||
if (typeof event.end !== "undefined") {
|
if (typeof event.end !== "undefined") {
|
||||||
@ -65,6 +65,9 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
endDate = startDate;
|
endDate = startDate;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// calculate the duration f the event for use with recurring events.
|
||||||
|
var duration = parseInt(endDate.format("x")) - parseInt(startDate.format("x"));
|
||||||
|
|
||||||
if (event.start.length === 8) {
|
if (event.start.length === 8) {
|
||||||
startDate = startDate.startOf("day");
|
startDate = startDate.startOf("day");
|
||||||
}
|
}
|
||||||
@ -75,12 +78,15 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
|
|
||||||
for (var d in dates) {
|
for (var d in dates) {
|
||||||
startDate = moment(new Date(dates[d]));
|
startDate = moment(new Date(dates[d]));
|
||||||
newEvents.push({
|
endDate = moment(parseInt(startDate.format("x")) + duration, 'x');
|
||||||
title: (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary,
|
if (endDate.format("x") > now) {
|
||||||
startDate: startDate.format("x"),
|
newEvents.push({
|
||||||
endDate: endDate.format("x"),
|
title: (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary,
|
||||||
fullDayEvent: isFullDayEvent(event)
|
startDate: startDate.format("x"),
|
||||||
});
|
endDate: endDate.format("x"),
|
||||||
|
fullDayEvent: isFullDayEvent(event)
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// console.log("Single event ...");
|
// console.log("Single event ...");
|
||||||
@ -119,6 +125,8 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
return a.startDate - b.startDate;
|
return a.startDate - b.startDate;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
//console.log(newEvents);
|
||||||
|
|
||||||
events = newEvents.slice(0, maximumEntries);
|
events = newEvents.slice(0, maximumEntries);
|
||||||
|
|
||||||
self.broadcastEvents();
|
self.broadcastEvents();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user