timestamp API
data/timestamp.tsx
TimestampProvider
Props
| Prop | Type | Default | Description |
|---|---|---|---|
children* | React.ReactNode | — | The subtree whose timestamps use these defaults. |
hour12 | boolean | undefined | the locale's convention | Force a 12-hour (true) or 24-hour (false) clock. |
locale | string | undefined | the browser locale | Validated once; an invalid tag falls back to the browser locale and is reported. |
messages | any | the English messages | Partial overrides of the English defaults. |
timeZone | string | undefined | the viewer's zone | Validated once with isSupportedTimeZone; an invalid zone falls back to the viewer's zone and is reported. |
Show native HTML props
Native HTML Props
| Prop | Type | Default | Description |
|---|---|---|---|
onError | ((issue: TimestampIssue) => void) | undefined | — | Receives invalid values, invalid configuration and copy failures; wire it to the app's structured logger. A function, so wrap the provider in your own `"use client"` component to pass it. |
useTimestamp
Timestamp
Props
| Prop | Type | Default | Description |
|---|---|---|---|
copyable | boolean | undefined | true | Whether clicking copies. Set false inside an `<a>` or a stretched-link card: renders a non-focusable span with a hover tooltip and no copy. In a row with its own onClick or onKeyDown, keep the default; the click, Enter and Space stop at the timestamp. |
direction | TooltipDirection | Side | undefined | TooltipDirection.Top | Side the tooltip prefers. |
format | TimestampFormat | "COMPACT" | "RELATIVE" | "CONTEXTUAL" | "TIME" | "ABSOLUTE" | "DATE" | undefined | TimestampFormat.Relative | How the visible label reads. |
hour12 | boolean | undefined | the nearest TimestampProvider, else the locale's convention | Force a 12-hour (true) or 24-hour (false) clock. |
locale | string | undefined | the nearest TimestampProvider, else the browser locale | BCP 47 locale. Invalid values fall back and are reported. |
ref | any | — | Ref to the root span, which exists in every state. |
timeZone | string | undefined | the nearest TimestampProvider, else the viewer's zone | IANA time zone. Invalid values fall back and are reported. |
Show native HTML props
Native HTML Props
| Prop | Type | Default | Description |
|---|---|---|---|
className | string | undefined | — | Extra classes on the root span. |
id | string | undefined | — | Id on the root span. |
onCopied | ((text: string) => void) | undefined | — | Called with the copied text after a successful copy. A function, so it cannot be passed from a Server Component. |
value* | any | — | The moment or calendar date to show. See TimestampValue. |