Add the clock widget: local time and date, bound to nothing

One second-tick interval and the browser's own locale formatting, so there
is no 12/24-hour setting to carry and nothing to bind.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HTsT1isxUjw5gtkJk8WhuA
This commit is contained in:
2026-08-20 08:35:21 +02:00
co-authored by Claude Opus 5
parent f4f8e77f33
commit 4c146e2a38
@@ -1,6 +1,36 @@
import { useEffect, useState } from "react"
import type { WidgetProps } from "./widgets" 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) { export function ClockWidget(_props: WidgetProps) {
return <p className="text-sm text-muted-foreground"></p> const [now, setNow] = useState(() => new Date())
useEffect(() => {
const timer = setInterval(() => setNow(new Date()), 1000)
return () => clearInterval(timer)
}, [])
return (
<div className="min-w-0">
<p className="truncate text-3xl tabular-nums" data-testid="clock-time">
{now.toLocaleTimeString(undefined, {
hour: "2-digit",
minute: "2-digit",
})}
</p>
<p className="truncate text-sm text-muted-foreground">
{now.toLocaleDateString(undefined, {
weekday: "long",
day: "numeric",
month: "long",
})}
</p>
</div>
)
} }