-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: extraction de la fonction getDuration dans un fichier utili…
…taire
- Loading branch information
1 parent
a2ffec3
commit e5533c5
Showing
4 changed files
with
15 additions
and
24 deletions.
There are no files selected for viewing
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,12 @@ | ||
export const lz = (num: number) => (num < 10 ? `0${num}` : num); | ||
|
||
export const getDuration = (minutes: number): string => { | ||
const durationHours = Math.floor(minutes / 60); | ||
const durationRemainingMinutes = minutes % 60; | ||
|
||
if(durationHours === 0) { | ||
return `${durationRemainingMinutes} min`; | ||
} | ||
|
||
return `${durationHours}h ${lz(durationRemainingMinutes)}min`; | ||
}; |
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
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
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