- Replace mobile placeholder with Expo Router app (tabs, playback, auth, library) - Move Convex backend to @otunes/convex for web and mobile reuse - Update web app imports and API routes to use shared package
31 lines
809 B
TypeScript
31 lines
809 B
TypeScript
export function formatDuration(seconds: number): string {
|
|
const total = Math.max(0, Math.floor(seconds))
|
|
const minutes = Math.floor(total / 60)
|
|
const remainingSeconds = total % 60
|
|
return `${minutes}:${remainingSeconds.toString().padStart(2, "0")}`
|
|
}
|
|
|
|
export function sumDurationSeconds(durations: number[]): number {
|
|
return durations.reduce((sum, value) => sum + value, 0)
|
|
}
|
|
|
|
export function formatMetadata(
|
|
genre: string | null,
|
|
year: number | null
|
|
): string | null {
|
|
const parts: string[] = []
|
|
if (genre) parts.push(genre)
|
|
if (year) parts.push(String(year))
|
|
return parts.length > 0 ? parts.join(" · ") : null
|
|
}
|
|
|
|
export function initialsFromName(name: string): string {
|
|
return (
|
|
name
|
|
.match(/\b(\w)/g)
|
|
?.join("")
|
|
.slice(0, 2)
|
|
.toUpperCase() ?? "NA"
|
|
)
|
|
}
|