mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-28 04:02:12 +00:00
Show relative time to non full day events. Fix: #162
This commit is contained in:
parent
f45a2e7806
commit
614e5e62af
@ -115,7 +115,12 @@ Module.register("calendar",{
|
|||||||
eventWrapper.appendChild(titleWrapper);
|
eventWrapper.appendChild(titleWrapper);
|
||||||
|
|
||||||
var timeWrapper = document.createElement("td");
|
var timeWrapper = document.createElement("td");
|
||||||
timeWrapper.innerHTML = (event.today) ? this.config.todayText : moment(event.startDate,"x").fromNow();
|
//console.log(event.today);
|
||||||
|
if (event.fullDayEvent) {
|
||||||
|
timeWrapper.innerHTML = (event.today) ? this.config.todayText : moment(event.startDate,"x").fromNow();
|
||||||
|
} else {
|
||||||
|
timeWrapper.innerHTML = moment(event.startDate,"x").fromNow();
|
||||||
|
}
|
||||||
// timeWrapper.innerHTML = moment(event.startDate,'x').format('lll');
|
// timeWrapper.innerHTML = moment(event.startDate,'x').format('lll');
|
||||||
timeWrapper.className = "time light";
|
timeWrapper.className = "time light";
|
||||||
eventWrapper.appendChild(timeWrapper);
|
eventWrapper.appendChild(timeWrapper);
|
||||||
|
@ -95,13 +95,34 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
|||||||
} else {
|
} else {
|
||||||
// console.log("Single event ...");
|
// console.log("Single event ...");
|
||||||
// Single event.
|
// Single event.
|
||||||
if (startDate >= today && startDate <= future) {
|
var fullDayEvent = (event.start.length === 8);
|
||||||
newEvents.push({
|
var title = (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary;
|
||||||
title: (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary,
|
|
||||||
startDate: startDate.format("x"),
|
if (!fullDayEvent && startDate < new Date()) {
|
||||||
fullDayEvent: (event.start.length === 8)
|
// it's not a fullday event, and it is in the past. So skip.
|
||||||
});
|
console.log("It's not a fullday event, and it is in the past. So skip: " + title);
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (fullDayEvent && startDate < today) {
|
||||||
|
// it's a fullday event, and it is before today. So skip.
|
||||||
|
console.log("It's a fullday event, and it is before today. So skip: " + title);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (startDate > future) {
|
||||||
|
// it exceeds the maximumNumberOfDays limit. So skip
|
||||||
|
console.log("It exceeds the maximumNumberOfDays limit. So skip: " + title);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Every thing is good. Add it to the list.
|
||||||
|
newEvents.push({
|
||||||
|
title: title,
|
||||||
|
startDate: startDate.format("x"),
|
||||||
|
fullDayEvent: fullDayEvent
|
||||||
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user