/**
 * Server status display utilities
 *
 * Extracted from DashboardPage and ServersPage.
 */

/** Vuetify chip color for server status */
export function statusChipColor(status: string): string {
  switch (status) {
    case 'online': return 'success'
    case 'offline': return 'error'
    default: return 'warning'
  }
}

/** Chinese label for server status */
export function statusLabel(status: string): string {
  switch (status) {
    case 'online': return '在线'
    case 'offline': return '离线'
    default: return '未知'
  }
}

/** Relative time formatting (Chinese) */
export function formatRelativeTime(t: string | null): string {
  if (!t) return '—'
  const date = new Date(t)
  if (isNaN(date.getTime())) return '—'
  const diff = Date.now() - date.getTime()
  if (diff < 60000) return '刚刚'
  if (diff < 3600000) return `${Math.floor(diff / 60000)} 分钟前`
  if (diff < 86400000) return `${Math.floor(diff / 3600000)} 小时前`
  return `${Math.floor(diff / 86400000)} 天前`
}
