mirror of
https://github.com/movie-web/native-app.git
synced 2025-09-13 16:53:25 +00:00
19 lines
584 B
TypeScript
19 lines
584 B
TypeScript
export const mapMillisecondsToTime = (milliseconds: number): string => {
|
|
const hours = Math.floor(milliseconds / (1000 * 60 * 60));
|
|
const minutes = Math.floor((milliseconds % (1000 * 60 * 60)) / (1000 * 60));
|
|
const seconds = Math.floor((milliseconds % (1000 * 60)) / 1000);
|
|
|
|
const components: string[] = [];
|
|
|
|
if (hours > 0) {
|
|
components.push(hours.toString().padStart(2, "0"));
|
|
}
|
|
|
|
components.push(minutes.toString().padStart(2, "0"));
|
|
components.push(seconds.toString().padStart(2, "0"));
|
|
|
|
const formattedTime = components.join(":");
|
|
|
|
return formattedTime;
|
|
};
|