fix display of end time

This commit is contained in:
Maximilian Krambach 2019-02-08 14:33:55 +01:00
parent ab557486cb
commit 382cf4ef96
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
* 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<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);
}

View File

@ -257,10 +257,16 @@ export class AgendaListComponent extends ListViewBaseComponent<ViewItem> 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;
}
}
}