export function formatTimestamp(time, options = {}) {
  if (!time || time < 10) return options.fallback ?? '-'
  return new Date(+time).toLocaleString('zh-CN', {
    year: 'numeric',
    month: '2-digit',
    day: '2-digit',
    hour: '2-digit',
    minute: '2-digit',
    second: options.withSeconds ? '2-digit' : undefined
  })
}

export function formatTimeOnly(time) {
  if (!time || time < 10) return '-'
  return new Date(+time).toLocaleString('zh-CN', { hour: '2-digit', minute: '2-digit' })
}

export function formatDateStr(date) {
  const y = date.getFullYear()
  const m = String(date.getMonth() + 1).padStart(2, '0')
  const d = String(date.getDate()).padStart(2, '0')
  return `${y}-${m}-${d}`
}

export function formatDateCompact(date) {
  const y = date.getFullYear()
  const m = String(date.getMonth() + 1).padStart(2, '0')
  const d = String(date.getDate()).padStart(2, '0')
  return `${y}${m}${d}`
}

export const WEEKDAY_OPTIONS = [
  { label: '星期日', value: 0 },
  { label: '星期一', value: 1 },
  { label: '星期二', value: 2 },
  { label: '星期三', value: 3 },
  { label: '星期四', value: 4 },
  { label: '星期五', value: 5 },
  { label: '星期六', value: 6 }
]

export function getWeekdayLabel(day) {
  return WEEKDAY_OPTIONS.find((item) => item.value === day)?.label || '未知'
}

export const RULE_MODE_MAP = {
  0: '随机占座',
  1: '志愿顺序占座',
  2: '志愿组顺序占座',
  3: '志愿优先',
  4: '志愿组优先'
}

export const RULE_MODE_OPTIONS = [
  { label: '随机占座', value: 0 },
  { label: '志愿顺序占座', value: 1 },
  { label: '志愿优先', value: 3 }
]
