33 lines
996 B
TypeScript
33 lines
996 B
TypeScript
/** German label helpers for enum values and lookups. */
|
|
import { de } from '../strings/de'
|
|
import type { Gender, GerbilStatus } from '../api/types'
|
|
|
|
export function genderLabel(gender: Gender): string {
|
|
return de.pages.gerbils.genderLabels[gender]
|
|
}
|
|
|
|
export function statusLabel(status: GerbilStatus): string {
|
|
return de.pages.gerbils.statusLabels[status]
|
|
}
|
|
|
|
/** Format an ISO date ("YYYY-MM-DD") as German "TT.MM.JJJJ"; null -> dash. */
|
|
export function formatDate(iso: string | null | undefined): string {
|
|
if (!iso) return '—'
|
|
const [y, m, d] = iso.split('-')
|
|
if (!y || !m || !d) return iso
|
|
return `${d}.${m}.${y}`
|
|
}
|
|
|
|
/** INBOX-1: ISO-Zeitstempel → "TT.MM.JJJJ, HH:MM" (lokale Zeit, de-DE). */
|
|
export function formatDateTime(iso: string): string {
|
|
const date = new Date(iso)
|
|
if (Number.isNaN(date.getTime())) return iso
|
|
return date.toLocaleString('de-DE', {
|
|
day: '2-digit',
|
|
month: '2-digit',
|
|
year: 'numeric',
|
|
hour: '2-digit',
|
|
minute: '2-digit',
|
|
})
|
|
}
|