export function formatNumber(value: number | undefined | null): string {
  if (value == null) return '0'
  return value.toLocaleString('zh-CN')
}

export function toFixed(value: number | undefined | null, digits = 2): string {
  if (value == null) return '0.00'
  return Number(value).toFixed(digits)
}

export function formatMinutes(minutes: number | undefined | null): string {
  if (!minutes) return '0分钟'
  if (minutes < 60) return `${minutes}分钟`
  const hours = Math.floor(minutes / 60)
  const mins = minutes % 60
  if (mins === 0) return `${hours}小时`
  return `${hours}小时${mins}分钟`
}
