Skip to content

useCurrentTimezone

Global (not per calendar) timezone state. Time slots are fetched from the API in this timezone and the formatters render in it.

ts
import { useCurrentTimezone } from "@zaptime/core";

const { timezone, setTimezone, clientOriginalTimezone } = useCurrentTimezone();

Client original timezone

The IANA timezone detected from the browser at load time, e.g. "Europe/Prague". Useful for a "reset" action.

ts
clientOriginalTimezone; // string

Current timezone

ts
timezone.value; // string

Set timezone

ts
setTimezone("America/New_York");
await useCalendar(calendarId).getDays(); // slots may move across days

setTimezone does not refetch by itself. Call getDays() afterwards.

Timezone list

The API serves the list of supported timezones for a picker:

ts
const res = await fetch("https://api.zaptime.app/timezones").then((r) => r.json());
res.data; // string[]