Time Zone Picker

Find a time zone by city, name, abbreviation or offset, with the reader's own zone first.

Workspace time zone

It's 8:30 PM there now (India Standard Time). The daily digest goes out at 8:00 AM.

Installation

pnpm dlx shadcn@latest add checkfu/uicontext/time-zone-picker

Usage

import { TimeZonePicker } from "./ui/uicontext/components/TimeZonePicker.ts"
const Message = UiSchema.TaggedEnum({ PickedZone: { value: Schema.String } })// `now` decides each zone's offset: Berlin is UTC+1 in winter and UTC+2 in summerexport const WorkspaceZone = (h: Html.H<typeof Message.Type>, zone: string, now: string) =>	TimeZonePicker(h, {		props: { label: "Time zone", value: zone, now },		onEmit: { Picked: ({ value }) => Message.PickedZone({ value }) },	})

API reference

Props

TimeZonePicker props
NameTypeDescription
valuerequiredTimeZoneIdThe zone, as an IANA name such as Europe/Berlin
nowrequiredstringThe app's current instant (ISO), for each zone's offset and name: they change with daylight saving
localZoneTimeZoneIdThe reader's own zone, listed first; the browser's when left out (pass it when rendering on a server)
localestring—
labelrequiredstring—
hideLabelboolean—
descriptionstring—
idstring—
namestring—
disabledboolean—

Events

TimeZonePicker events
EventPayloadDescription
Picked{ value: TimeZoneId }A zone was picked: store it and pass it back as value

Agent actions

What agents can do with TimeZonePicker
ActionDescription
PickedZonePick a time zone by its IANA name, such as Europe/Berlin

Source