Show relative time to non full day events. Fix: #162

This commit is contained in:
Michael Teeuw 2016-04-15 12:50:34 +02:00
parent f45a2e7806
commit 614e5e62af
2 changed files with 33 additions and 7 deletions

View File

@ -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);

View File

@ -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
});
} }
} }
} }