Skip to content

Commit

Permalink
Improve formatDuration (#713)
Browse files Browse the repository at this point in the history
* Update formatDuration.ts

* fix formatting

* fix formatting

* Fix formatting
  • Loading branch information
Altonss authored Jan 22, 2025
1 parent 59df452 commit 34f8b95
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion ui/src/lib/formatDuration.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
export const formatDurationSec = (t: number): string => {
const hours = Math.floor(t / 3600);
const minutes = Math.ceil((t - hours * 3600) / 60);
const str = [hours !== 0 ? hours + ' h' : '', minutes !== 0 ? minutes + ' min' : '']
const str = [
hours !== 0 ? hours + ' h' : '',
minutes !== 0 || hours === 0 ? minutes + ' min' : ''
]
.join(' ')
.trim();
return str;
Expand Down

0 comments on commit 34f8b95

Please sign in to comment.