Merge pull request #2737 from rejas/RelativeFullDayEvents

Resubmit of "Relative full day events"
This commit is contained in:
Michael Teeuw 2021-12-21 19:42:47 +01:00 committed by GitHub
commit c3e507234d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 16 additions and 4 deletions

View File

@ -39,6 +39,7 @@ _This release is scheduled to be released on 2022-01-01._
### Fixed ### Fixed
- Fixed error when accessing letsencrypt certificates - Fixed error when accessing letsencrypt certificates
- Fixed Calendar module enhancement: displaying full events without time (#2424)
## [2.17.0] - 2021-10-01 ## [2.17.0] - 2021-10-01

View File

@ -368,9 +368,9 @@ 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) { 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 }));
} else { } else {
timeWrapper.innerHTML = this.capFirst( timeWrapper.innerHTML = this.capFirst(
@ -378,11 +378,22 @@ Module.register("calendar", {
sameDay: "[" + this.translate("TODAY") + "]", sameDay: "[" + this.translate("TODAY") + "]",
nextDay: "[" + this.translate("TOMORROW") + "]", nextDay: "[" + this.translate("TOMORROW") + "]",
nextWeek: "dddd", nextWeek: "dddd",
sameElse: this.config.dateFormat sameElse: event.fullDayEvent ? this.config.fullDayEventDateFormat : this.config.dateFormat
}) })
); );
} }
if (event.startDate - now < this.config.getRelative * oneHour) { if (event.fullDayEvent) {
// Full days events within the next two days
if (event.today) {
timeWrapper.innerHTML = this.capFirst(this.translate("TODAY"));
} else if (event.startDate - now < oneDay && event.startDate - now > 0) {
timeWrapper.innerHTML = this.capFirst(this.translate("TOMORROW"));
} else if (event.startDate - now < 2 * oneDay && event.startDate - now > 0) {
if (this.translate("DAYAFTERTOMORROW") !== "DAYAFTERTOMORROW") {
timeWrapper.innerHTML = this.capFirst(this.translate("DAYAFTERTOMORROW"));
}
}
} else if (event.startDate - now < this.config.getRelative * oneHour) {
// If event is within getRelative hours, display 'in xxx' time format or moment.fromNow() // If event is within getRelative hours, display 'in xxx' time format or moment.fromNow()
timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow()); timeWrapper.innerHTML = this.capFirst(moment(event.startDate, "x").fromNow());
} }