18 lines
633 B
TypeScript
18 lines
633 B
TypeScript
|
|
// Renders a naive local datetime string (e.g. "2026-06-25T14:30:00", no Z/offset)
|
||
|
|
// as "DD.MM.YYYY HH:MM". Because occurred_at carries no timezone, new Date()
|
||
|
|
// parses it as local time and the user-typed HH:MM is preserved.
|
||
|
|
export const formatEventDateTime = (s: string): string => {
|
||
|
|
const d = new Date(s)
|
||
|
|
if (Number.isNaN(d.getTime())) return s
|
||
|
|
return d
|
||
|
|
.toLocaleString('de-DE', {
|
||
|
|
day: '2-digit',
|
||
|
|
month: '2-digit',
|
||
|
|
year: 'numeric',
|
||
|
|
hour: '2-digit',
|
||
|
|
minute: '2-digit',
|
||
|
|
})
|
||
|
|
// de-DE renders as "25.06.2026, 14:30" — drop the comma to get "25.06.2026 14:30".
|
||
|
|
.replace(',', '')
|
||
|
|
}
|