forked from Ninjalama/streamyfin_mirror
feat: formatting function
This commit is contained in:
@@ -6,7 +6,7 @@
|
||||
* @returns A string formatted as "Xh Ym" where X is hours and Y is minutes.
|
||||
*/
|
||||
export const runtimeTicksToMinutes = (
|
||||
ticks: number | null | undefined
|
||||
ticks: number | null | undefined,
|
||||
): string => {
|
||||
if (!ticks) return "0h 0m";
|
||||
|
||||
@@ -18,3 +18,19 @@ export const runtimeTicksToMinutes = (
|
||||
|
||||
return `${hours}h ${minutes}m`;
|
||||
};
|
||||
|
||||
export const runtimeTicksToSeconds = (
|
||||
ticks: number | null | undefined,
|
||||
): string => {
|
||||
if (!ticks) return "0h 0m";
|
||||
|
||||
const ticksPerMinute = 600000000;
|
||||
const ticksPerHour = 36000000000;
|
||||
|
||||
const hours = Math.floor(ticks / ticksPerHour);
|
||||
const minutes = Math.floor((ticks % ticksPerHour) / ticksPerMinute);
|
||||
const seconds = Math.floor((ticks % ticksPerMinute) / 10000000);
|
||||
|
||||
if (hours > 0) return `${hours}h ${minutes}m ${seconds}s`;
|
||||
else return `${minutes}m ${seconds}s`;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user