Clock

@sushindustries/ui

The reader's own day and time, in the reader's own zone, without asking anybody for a location.

5 min read
View as MarkdownEdit on GitHub

Props

PropTypeDefaultDoes
every?number15_000How often to re-read the time, in milliseconds. A clock showing minutes has no reason to tick every second: fifteen seconds is close enough that the displayed minute is never wrong for long, and it is four wake-ups a minute instead of sixty.
options?Intl.DateTimeFormatOptionsDEFAULTPassed straight to Intl.DateTimeFormat.
placeholder?string"--:--"Shown until the first client render.

Notes

options is passed straight to Intl.DateTimeFormat with no validation - an invalid combination throws inside the effect, exactly as it would calling the constructor by hand. every and options are independent: nothing keeps a fast interval in step with a coarse format or the other way round, so pick both together (see Guides).

placeholder only ever appears once, before the first tick. There is no prop that brings it back once a real time has been read.