Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,12 @@ This project adheres to [Semantic Versioning](https://semver.org/).

_This release is scheduled to be released on 2024-07-01._

Thanks to: @kleinmantara (to be continued before release)

### Added

- [calendar] Added config option "showEndsOnlyWithDuration" for default calendar

### Removed

- [test suite] delete node v18 support
Expand Down
15 changes: 12 additions & 3 deletions modules/default/calendar/calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Module.register("calendar", {
dateEndFormat: "LT",
fullDayEventDateFormat: "MMM Do",
showEnd: false,
showEndsOnlyWithDuration: false,
getRelative: 6,
hidePrivate: false,
hideOngoing: false,
Expand Down Expand Up @@ -388,7 +389,11 @@ Module.register("calendar", {

// Add endDate to dataheaders if showEnd is enabled
if (this.config.showEnd) {
timeWrapper.innerHTML += ` - ${CalendarUtils.capFirst(moment(event.endDate, "x").format("LT"))}`;
if (this.config.showEndsOnlyWithDuration && event.startDate === event.endDate) {
// no duration here, don't display end
} else {
timeWrapper.innerHTML += ` - ${CalendarUtils.capFirst(moment(event.endDate, "x").format("LT"))}`;
}
}

eventWrapper.appendChild(timeWrapper);
Expand All @@ -407,8 +412,12 @@ Module.register("calendar", {
timeWrapper.innerHTML = CalendarUtils.capFirst(moment(event.startDate, "x").format(this.config.dateFormat));
// Add end time if showEnd
if (this.config.showEnd) {
timeWrapper.innerHTML += "-";
timeWrapper.innerHTML += CalendarUtils.capFirst(moment(event.endDate, "x").format(this.config.dateEndFormat));
if (this.config.showEndsOnlyWithDuration && event.startDate === event.endDate) {
// no duration here, don't display end
} else {
timeWrapper.innerHTML += "-";
timeWrapper.innerHTML += CalendarUtils.capFirst(moment(event.endDate, "x").format(this.config.dateEndFormat));
}
}
// For full day events we use the fullDayEventDateFormat
if (event.fullDayEvent) {
Expand Down