Merge pull request #4284 from MaximilianKrambach/noEnd

fix display of end time
This commit is contained in:
Sean 2019-02-08 14:51:44 +01:00 committed by GitHub
commit 86ee11f9c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 7 deletions

View File

@ -273,11 +273,15 @@ export class ItemRepositoryService extends BaseRepository<ViewItem, Item> {
* Calculates the estimated end time based on the configured start and the * Calculates the estimated end time based on the configured start and the
* sum of durations of all agenda items * sum of durations of all agenda items
* *
* @returns a Date object * @returns a Date object or null
*/ */
public calculateEndTime(): Date { public calculateEndTime(): Date {
const startTime = this.config.instant<number>('agenda_start_event_date_time'); // a timestamp const startTime = this.config.instant<number>('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); return new Date(startTime + durationTime);
} }

View File

@ -257,10 +257,16 @@ export class AgendaListComponent extends ListViewBaseComponent<ViewItem> impleme
return ''; return '';
} }
const durationString = this.durationService.durationToString(duration); const durationString = this.durationService.durationToString(duration);
const endTimeString = this.repo const endTime = this.repo.calculateEndTime();
.calculateEndTime() const result = `${this.translate.instant('Duration')}: ${durationString}`;
.toLocaleTimeString(this.translate.currentLang, { hour: 'numeric', minute: 'numeric' }); if (endTime) {
return `${this.translate.instant('Duration')}: ${durationString} (${this.translate.instant('Estimated end')}: return (
${endTimeString} h)`; result +
` (${this.translate.instant('Estimated end')}:
${endTime.toLocaleTimeString(this.translate.currentLang, { hour: 'numeric', minute: 'numeric' })} h)`
);
} else {
return result;
}
} }
} }