Skip to content

Time zones

With the Luxon or Temporal adapter the calendar shows any IANA time zone: days start at its midnight and times are its wall-clock times, wherever the user is.

Result· switch the zone: the same events move to its wall-clock times

Dates stay Dates, that is moments in time. Only how they are laid out changes.

new LuxonAdapter({ locale: "en-US", timeZone: "America/New_York" });

With @weekwise/adapter-temporal the calendar takes and gives Temporal.ZonedDateTimes: viewValue, eventTimeFrameResolver, onEventChange and the other date props use it.

import { TemporalAdapter } from "@weekwise/adapter-temporal";
const adapter = new TemporalAdapter({ locale: "en-US", timeZone: "America/New_York" });
<DateLocalizationProvider adapter={adapter}>
<Calendar
items={meetings}
eventTimeFrameResolver={(m) => ({ start: m.start, end: m.end })}
onEventChange={(m, start, end) => save(m.id, start, end)} // ZonedDateTime in New York
>
{(m) => m.title}
</Calendar>
</DateLocalizationProvider>

Dates you give the calendar may be in any zone: a meeting at 09:00 in Berlin shows at 03:00 in New York. Switching the adapter to another zone keeps the day the user sees. A day stays 24 wall-clock hours long on daylight saving days.

The adapter uses the global Temporal. Where the runtime has none, load a polyfill first, e.g. import "temporal-polyfill/global". For TypeScript, add "ESNext.Temporal" to lib (TypeScript 6+) or use the polyfill’s global types.

withTimeZone(zone) and withLocale(locale) return a copy with the other settings kept. from(value) reads an Instant, PlainDateTime, PlainDate, Date or epoch nanoseconds as a ZonedDateTime in the adapter’s zone.