mirror of
https://github.com/streamyfin/streamyfin.git
synced 2026-07-19 10:44:18 +01:00
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.
|
* @returns A string formatted as "Xh Ym" where X is hours and Y is minutes.
|
||||||
*/
|
*/
|
||||||
export const runtimeTicksToMinutes = (
|
export const runtimeTicksToMinutes = (
|
||||||
ticks: number | null | undefined
|
ticks: number | null | undefined,
|
||||||
): string => {
|
): string => {
|
||||||
if (!ticks) return "0h 0m";
|
if (!ticks) return "0h 0m";
|
||||||
|
|
||||||
@@ -18,3 +18,19 @@ export const runtimeTicksToMinutes = (
|
|||||||
|
|
||||||
return `${hours}h ${minutes}m`;
|
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