diff --git a/client/src/app/core/repositories/agenda/item-repository.service.ts b/client/src/app/core/repositories/agenda/item-repository.service.ts index bb477ca69..7071a52df 100644 --- a/client/src/app/core/repositories/agenda/item-repository.service.ts +++ b/client/src/app/core/repositories/agenda/item-repository.service.ts @@ -273,11 +273,15 @@ export class ItemRepositoryService extends BaseRepository { * Calculates the estimated end time based on the configured start and the * sum of durations of all agenda items * - * @returns a Date object + * @returns a Date object or null */ public calculateEndTime(): Date { const startTime = this.config.instant('agenda_start_event_date_time'); // a timestamp - const durationTime = this.calculateDuration() * 60 * 1000; // minutes to miliseconds + const duration = this.calculateDuration(); + if (!startTime || !duration) { + return null; + } + const durationTime = duration * 60 * 1000; // minutes to miliseconds return new Date(startTime + durationTime); } diff --git a/client/src/app/site/agenda/components/agenda-list/agenda-list.component.ts b/client/src/app/site/agenda/components/agenda-list/agenda-list.component.ts index 458b15810..d4eb33594 100644 --- a/client/src/app/site/agenda/components/agenda-list/agenda-list.component.ts +++ b/client/src/app/site/agenda/components/agenda-list/agenda-list.component.ts @@ -257,10 +257,16 @@ export class AgendaListComponent extends ListViewBaseComponent impleme return ''; } const durationString = this.durationService.durationToString(duration); - const endTimeString = this.repo - .calculateEndTime() - .toLocaleTimeString(this.translate.currentLang, { hour: 'numeric', minute: 'numeric' }); - return `${this.translate.instant('Duration')}: ${durationString} (${this.translate.instant('Estimated end')}: - ${endTimeString} h)`; + const endTime = this.repo.calculateEndTime(); + const result = `${this.translate.instant('Duration')}: ${durationString}`; + if (endTime) { + return ( + result + + ` (${this.translate.instant('Estimated end')}: + ${endTime.toLocaleTimeString(this.translate.currentLang, { hour: 'numeric', minute: 'numeric' })} h)` + ); + } else { + return result; + } } }