MCPcopy
hub / github.com/doublesymmetry/react-native-track-player / format

Function format

example/src/lib/formatTime.ts:1–13  ·  view source on GitHub ↗
(totalSeconds: number)

Source from the content-addressed store, hash-verified

1function format(totalSeconds: number): string {
2 if (!Number.isFinite(totalSeconds) || totalSeconds < 0) {
3 return '0:00';
4 }
5 const seconds = Math.floor(totalSeconds % 60);
6 const minutes = Math.floor((totalSeconds / 60) % 60);
7 const hours = Math.floor(totalSeconds / 3600);
8 const pad = (n: number) => n.toString().padStart(2, '0');
9 if (hours > 0) {
10 return `${hours}:${pad(minutes)}:${pad(seconds)}`;
11 }
12 return `${minutes}:${pad(seconds)}`;
13}
14
15export function formatTime(seconds: number): string {
16 return format(seconds);

Callers 2

formatTimeFunction · 0.85
formatDurationFunction · 0.85

Calls 1

padFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…