diff --git a/frontend/src/components/Dashboard/ClockWidget.tsx b/frontend/src/components/Dashboard/ClockWidget.tsx index bef1b89..2b81ab4 100644 --- a/frontend/src/components/Dashboard/ClockWidget.tsx +++ b/frontend/src/components/Dashboard/ClockWidget.tsx @@ -1,6 +1,36 @@ +import { useEffect, useState } from "react" + import type { WidgetProps } from "./widgets" -/** A clock — a stub until the clock widget is written. */ +/** + * Local time and date, read from the browser rather than from the graph. + * + * The tick is a plain one-second interval and the formatting is the browser's + * own locale, so there is no 12/24-hour setting to carry. + */ export function ClockWidget(_props: WidgetProps) { - return
—
+ const [now, setNow] = useState(() => new Date()) + + useEffect(() => { + const timer = setInterval(() => setNow(new Date()), 1000) + return () => clearInterval(timer) + }, []) + + return ( ++ {now.toLocaleTimeString(undefined, { + hour: "2-digit", + minute: "2-digit", + })} +
++ {now.toLocaleDateString(undefined, { + weekday: "long", + day: "numeric", + month: "long", + })} +
+