Scheduler · Configuring the view
Time zone
Meetings are stored as New York wall-clock strings (dataTimezone) and shown in the zone picked with displayTimezone — today, the current-time line and every drag follow it.
Live demo
Switch to Tokyo · Move a meeting, then switch back to New York
Fullscreenimport { useState } from "react"
import { ProScheduler } from "@andreisaac/pro-scheduler"
import { dataZone, globalMeetings, globalTeam } from "./data/global"
import { Choice, Toolbar, useEvents } from "./kit"
/** The zones a viewer can pick: each member's, by city. */
const zones = globalTeam.map((m) => ({ zone: m.timezone, label: m.city }))
function ZonePicker({ value, onChange }: { value: string; onChange: (zone: string) => void }) {
return (
<Toolbar label="Display time zone">
{zones.map((z) => (
<Choice key={z.zone} active={value === z.zone} onClick={() => onChange(z.zone)}>
{z.label}
</Choice>
))}
</Toolbar>
)
}
export function SchedulerTimezoneDemo() {
// Stored as New York wall-clock strings; shown in the picked zone.
const { events, handlers } = useEvents(() => globalMeetings())
const [zone, setZone] = useState("Europe/Lisbon")
return (
<>
<ZonePicker value={zone} onChange={setZone} />
<ProScheduler
data={events}
resources={globalTeam}
dataTimezone={dataZone}
displayTimezone={zone}
view={{ scheduler: { type: "week" } }}
height={600}
{...handlers}
/>
</>
)
}// data/global.ts — sample data, relative to the current week or month.
import type { SchedulerEvent, SchedulerResource } from "@andreisaac/pro-scheduler"
import { weekStart } from "./studio"
export type Member = SchedulerResource & { id: string; timezone: string; city: string }
export const globalTeam: Member[] = [
{ id: "maya", name: "Maya", city: "San Francisco", timezone: "America/Los_Angeles", color: "#2563eb" },
{ id: "leo", name: "Leo", city: "New York", timezone: "America/New_York", color: "#059669" },
{ id: "ines", name: "Inês", city: "Lisbon", timezone: "Europe/Lisbon", color: "#d97706" },
{ id: "arjun", name: "Arjun", city: "Bengaluru", timezone: "Asia/Kolkata", color: "#7c3aed" },
{ id: "yuki", name: "Yuki", city: "Tokyo", timezone: "Asia/Tokyo", color: "#db2777" },
]
export const dataZone = "America/New_York"
/** "YYYY-MM-DDTHH:MM" for day `day` of this week, at New York time `hour:minute`. */
function ny(base: Date, day: number, hour: number, minute = 0) {
const d = new Date(base.getFullYear(), base.getMonth(), base.getDate() + day)
const p = (n: number) => String(n).padStart(2, "0")
return `${d.getFullYear()}-${p(d.getMonth() + 1)}-${p(d.getDate())}T${p(hour)}:${p(minute)}`
}
export function globalMeetings(base = weekStart()): SchedulerEvent[] {
return [
{ id: "sync", title: "Global sync", start: ny(base, 0, 8), end: ny(base, 0, 9), resource: ["maya", "leo", "ines", "arjun"], recurring: "FREQ=WEEKLY;BYDAY=MO,TH" },
{ id: "design", title: "Design review", start: ny(base, 1, 11), end: ny(base, 1, 12), resource: ["maya", "leo", "ines"] },
{ id: "apac", title: "APAC handover", start: ny(base, 1, 20), end: ny(base, 1, 20, 30), resource: ["leo", "arjun", "yuki"], recurring: { repeat: "weekly", weekDays: "TU,WE,TH" } },
{ id: "infra", title: "Infra on-call", start: ny(base, 2, 3), end: ny(base, 2, 5), resource: ["arjun", "yuki"] },
{ id: "customer", title: "Customer call", start: ny(base, 3, 13), end: ny(base, 3, 14), resource: ["leo", "maya"] },
{ id: "planning", title: "Quarterly planning", start: ny(base, 4, 9), end: ny(base, 4, 11), resource: ["maya", "leo", "ines", "arjun", "yuki"] },
]
}About this demo
Meetings are stored as New York wall-clock strings (dataTimezone) and shown in the zone picked with displayTimezone — today, the current-time line and every drag follow it.
Changes come back in the data's own format: New York wall-clock strings.
Things to try
- Switch to Tokyo
- Move a meeting, then switch back to New York
The props behind it are explained in Recurrence, time zones and order.