Skip to content

Commit

Permalink
Change duration of request of speakers to hours:mins (#2948)
Browse files Browse the repository at this point in the history
  • Loading branch information
reiterl authored Nov 1, 2023
1 parent 2c0b95f commit 57592b6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<tr>
<td>{{ 'Duration of all requests to speak' | translate }}</td>
<!-- I believe we had a pipe fot that, but could not find it -->
<td>{{ parseDuration(totalSpeakingTime | async) }}</td>
<td>{{ parseDuration(totalSpeakingTime | async, true) }}</td>
</tr>
</table>
<os-list
Expand All @@ -38,7 +38,7 @@
</div>
<div *osScrollingTableCell="'durationOfWordRequests'; row as object; config: { width: '100px' }">
<div *osScrollingTableCellLabel>{{ 'Duration of requests to speak' | translate }}</div>
{{ parseDuration(object.speakingTime) }}
{{ parseDuration(object.speakingTime, true) }}
</div>
<div *osScrollingTableCell="'numberOfWordRequests'; row as object; config: { width: '50px' }">
<div *osScrollingTableCellLabel>{{ 'Number of requests to speak' | translate }}</div>
Expand Down
6 changes: 3 additions & 3 deletions client/src/app/site/services/duration.service.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ describe(`DurationService`, () => {
});

it(`test durationToStringWithHours`, () => {
expect(service.durationToStringWithHours(83)).toBe(`0:01:23 h`);
expect(service.durationToStringWithHours(7345)).toBe(`2:02:25 h`);
expect(service.durationToStringWithHours(-1)).toBe(`-0:00:01 h`);
expect(service.durationToStringWithHours(83)).toBe(`0:01 h`);
expect(service.durationToStringWithHours(7345)).toBe(`2:02 h`);
expect(service.durationToStringWithHours(-1)).toBe(`-0:00 h`);
expect(service.durationToStringWithHours(undefined)).toBe(``);
});

Expand Down
7 changes: 3 additions & 4 deletions client/src/app/site/services/duration.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class DurationService {
}

/**
* Calculates a given time to a readable string, that contains hours, minutes and seconds.
* Calculates a given time to a readable string, that contains hours and minutes.
*
* @param duration The time as number (in seconds).
*
Expand All @@ -77,9 +77,8 @@ export class DurationService {
}
const hours = Math.floor(duration / 3600);
const minutes = `0${Math.floor((duration % 3600) / 60)}`.slice(-2);
const seconds = `0${Math.floor(duration % 60)}`.slice(-2);
if (!isNaN(+minutes) && !isNaN(+seconds)) {
return `${prefix}${hours}:${minutes}:${seconds} h`;
if (!isNaN(+minutes)) {
return `${prefix}${hours}:${minutes} h`;
} else {
return ``;
}
Expand Down

0 comments on commit 57592b6

Please sign in to comment.