Don't display 'in xxx' for all day events when using relative times

This commit is contained in:
AmpioRosso 2021-11-06 15:03:08 +01:00
parent 46b63f52fe
commit 1af282a7a1

View File

@ -368,7 +368,7 @@ Module.register("calendar", {
} }
} else { } else {
// Show relative times // Show relative times
if (event.startDate >= now) { if ((event.startDate >= now) || (event.fullDayEvent && event.today)) {
// Use relative time // Use relative time
if ((!this.config.hideTime) && (!event.fullDayEvent)) { if ((!this.config.hideTime) && (!event.fullDayEvent)) {
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").calendar(null, { sameElse: this.config.dateFormat })); timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").calendar(null, { sameElse: this.config.dateFormat }));
@ -382,10 +382,7 @@ Module.register("calendar", {
}) })
); );
} }
if (event.startDate - now < this.config.getRelative * oneHour) { if (event.fullDayEvent) {
// If event is within getRelative hours, display 'in xxx' time format or moment.fromNow()
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
} else if (event.fullDayEvent) {
// Full days events within the next two days // Full days events within the next two days
if (event.today) { if (event.today) {
timeWrapper.innerHTML = this.capFirst(this.translate("TODAY")); timeWrapper.innerHTML = this.capFirst(this.translate("TODAY"));
@ -396,8 +393,10 @@ Module.register("calendar", {
timeWrapper.innerHTML = this.capFirst(this.translate("DAYAFTERTOMORROW")); timeWrapper.innerHTML = this.capFirst(this.translate("DAYAFTERTOMORROW"));
} }
} }
} } else if (event.startDate - now < this.config.getRelative * oneHour) {
} else { // If event is within getRelative hours, display 'in xxx' time format or moment.fromNow()
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
} } else {
// Ongoing event // Ongoing event
timeWrapper.innerHTML = this.capFirst( timeWrapper.innerHTML = this.capFirst(
this.translate("RUNNING", { this.translate("RUNNING", {