'use client'; import { useEffect, useState } from 'react'; import type { WidgetProps } from '../widget-registry'; import { CLOCK_DATE_FACTOR, resolveClockTimeFontSizePt } from './clock-font-size'; /** * Digital clock widget displaying time in a configurable timezone. * Uses Intl.DateTimeFormat — never computes UTC offsets manually (RESEARCH). * * Config: * - timezone: IANA timezone string (default 'Europe/Berlin') * - showDate: boolean (default false) — show date below time * - timeFontSizePt: number | null (quick-260916-bwo) — feste Schriftgroesse der * Uhrzeit in Punkt; leer/null = automatisch ueber Container-Queries mit der * Kachelgroesse. Grenzen 8..200 in `clock-font-size.ts` (T-BWO-01). */ export function ClockWidget({ config }: WidgetProps) { const timezone = (config.timezone as string) || 'Europe/Berlin'; const showDate = config.showDate === true; const fixedPt = resolveClockTimeFontSizePt(config); const [now, setNow] = useState(() => new Date()); useEffect(() => { const timer = setInterval(() => { setNow(new Date()); }, 1000); return () => clearInterval(timer); }, []); const timeFormatter = new Intl.DateTimeFormat('de-DE', { hour: '2-digit', minute: '2-digit', second: '2-digit', timeZone: timezone, }); const dateFormatter = new Intl.DateTimeFormat('de-DE', { day: '2-digit', month: 'long', year: 'numeric', timeZone: timezone, }); return (