Merge pull request #5447 from tsiegleauq/allow-negative-duration
Allow negative duration
This commit is contained in:
commit
cb190331f3
@ -88,10 +88,11 @@ export class DurationService {
|
||||
* @returns a more human readable time representation
|
||||
*/
|
||||
public durationToString(duration: number, suffix: 'h' | 'm'): string {
|
||||
const major = Math.floor(duration / 60);
|
||||
const major = duration < 0 ? Math.ceil(duration / 60) : Math.floor(duration / 60);
|
||||
const minor = `0${duration % 60}`.slice(-2);
|
||||
if (!isNaN(+major) && !isNaN(+minor)) {
|
||||
return `${major}:${minor} ${suffix}`;
|
||||
// converting the number '-0' to string results in '0'
|
||||
return `${major === -0 ? '-' + major : major}:${minor} ${suffix}`;
|
||||
} else {
|
||||
return '';
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user