mirror of
https://github.com/MichMich/MagicMirror.git
synced 2025-06-27 11:50:00 +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);
|
||||
|
||||
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.className = "time light";
|
||||
eventWrapper.appendChild(timeWrapper);
|
||||
|
@ -95,13 +95,34 @@ var CalendarFetcher = function(url, reloadInterval, maximumEntries, maximumNumbe
|
||||
} else {
|
||||
// console.log("Single event ...");
|
||||
// Single event.
|
||||
if (startDate >= today && startDate <= future) {
|
||||
newEvents.push({
|
||||
title: (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary,
|
||||
startDate: startDate.format("x"),
|
||||
fullDayEvent: (event.start.length === 8)
|
||||
});
|
||||
var fullDayEvent = (event.start.length === 8);
|
||||
var title = (typeof event.summary.val !== "undefined") ? event.summary.val : event.summary;
|
||||
|
||||
if (!fullDayEvent && startDate < new Date()) {
|
||||
// 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