forked from b00tc4mp/isdi-parttime-202403
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added assets and a formatting utility function b00tc4mp#175
- Loading branch information
1 parent
1184197
commit e302f46
Showing
6 changed files
with
20 additions
and
0 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
18 changes: 18 additions & 0 deletions
18
staff/daniel-hernandez/project/app/src/utils/formatSeconds.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
const formatSeconds = totalSeconds => { | ||
if (totalSeconds < 0) return '00:00'; | ||
|
||
const hours = Math.floor(totalSeconds / 3600); | ||
const minutes = Math.floor((totalSeconds % 3600) / 60); | ||
const seconds = totalSeconds % 60; | ||
|
||
const formattedMinutes = minutes.toString().padStart(2, '0'); | ||
const formattedSeconds = seconds.toString().padStart(2, '0'); | ||
|
||
if (hours > 0) { | ||
const formattedHours = hours.toString().padStart(2, '0'); | ||
return `${formattedHours}:${formattedMinutes}:${formattedSeconds}`; | ||
} | ||
return `${formattedMinutes}:${formattedSeconds}`; | ||
}; | ||
|
||
export default formatSeconds; |