/** Gemeinsame Typen der Cockpit-Module */

export interface JournalEntry {
  id: string
  time: string
  what: string
  who: string | null
  done: boolean
  doneAt: string | null
  isCorrected?: boolean
  correctionOfId?: string | null
}

export interface JournalCheckItem {
  id: string
  label: string
  confirmed: boolean
  confirmedAt: string | null
  ok: boolean
  okAt: string | null
}

export interface JournalPendenz {
  id: string
  what: string
  who: string | null
  whenHow: string | null
  done: boolean
  doneAt: string | null
}

export function formatTime(dateStr: string) {
  return new Date(dateStr).toLocaleTimeString('de-CH', { hour: '2-digit', minute: '2-digit' })
}

export function formatDateTime(dateStr: string) {
  const d = new Date(dateStr)
  return d.toLocaleDateString('de-CH', { day: '2-digit', month: '2-digit' }) + ' ' +
    d.toLocaleTimeString('de-CH', { hour: '2-digit', minute: '2-digit' })
}
