Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | 29x 26x 8x 8x 8x | /**
* Format a duration in minutes to a human-readable string.
* Examples:
* - 30 -> "30 min"
* - 60 -> "1h"
* - 90 -> "1h 30m"
*
* @param minutes - Duration in minutes, or null/undefined
* @returns Formatted string, or null if input is falsy
*/
export function formatTime(minutes: number | null | undefined): string | null {
if (!minutes) return null
if (minutes < 60) return `${minutes} min`
const hours = Math.floor(minutes / 60)
const mins = minutes % 60
return mins > 0 ? `${hours}h ${mins}m` : `${hours}h`
}
|