Scheduler - 타임존
Scheduler - 타임존 (Timezone)
서로 다른 타임존에서도 이벤트를 올바르게 표시하는 방법을 알아봐요. 이벤트가 어느 시각 기준으로 해석되는지, 화면에는 어떤 타임존으로 그려지는지가 핵심이에요.
본문
개요
Event Calendar와 Event Timeline은 이벤트 날짜(start와 end)를 문자열로 받으며, 형식에 따라 두 가지 의미론을 지원해요:
- Instant 문자열은
"Z"로 끝나며 UTC의 고정된 시점을 나타내요. 예:"2024-01-10T13:00:00Z". - Wall-time 문자열은
"Z"접미사가 없으며, 이벤트의timezone에서 해석되는 로컬 날짜/시간을 나타내요. 예:"2024-01-10T09:00:00".
모든 이벤트는 displayTimezone prop에 정의된 타임존으로 렌더링돼요.
이벤트 날짜 값
Instant 문자열 (Z 포함)
"Z"로 끝나는 문자열은 시간상의 고정된 시점을 나타내요.
const event = {
id: '1',
title: 'Team sync',
start: '2024-01-10T13:00:00Z', // 13:00 UTC
end: '2024-01-10T14:00:00Z',
};
이 이벤트는 다음과 같이 표시돼요:
Europe/Paris(UTC+1)에서는14:00America/New_York(UTC−5)에서는08:00
Wall-time 문자열 (Z 없음)
"Z" 접미사가 없는 문자열은 로컬 시간을 나타내요.
이 값은 event.timezone에서 해석돼요(타임존이 설정되지 않았다면 "default").
const event = {
id: '1',
title: 'Morning standup',
start: '2024-01-10T09:00:00', // 뉴욕에서 09:00 로컬 시간
end: '2024-01-10T09:30:00',
timezone: 'America/New_York',
};
이 이벤트는 DST(일광 절약 시간제) 변경과 관계없이 항상 뉴욕에서 09:00에 발생해요.
import * as React from 'react';
import { EventCalendar } from '@mui/x-scheduler/event-calendar';
import {
defaultVisibleDate,
initialEvents,
resources,
} from '../datasets/timezone-wall-time-events';
export default function TimezoneDatasetWallTime() {
const [events, setEvents] = React.useState(initialEvents);
return (
<div style={{ height: '600px', width: '100%' }}>
<EventCalendar
events={events}
resources={resources}
defaultVisibleDate={defaultVisibleDate}
onEventsChange={setEvents}
defaultPreferences={{ isSidePanelOpen: false }}
displayTimezone="Europe/Paris"
/>
</div>
);
}
timezone 필드
이벤트의 timezone 필드는 다음을 결정해요:
- Wall-time 문자열을 어떻게 해석할지:
"2024-01-10T09:00:00"시작에timezone: "America/New_York"가 있으면 뉴욕에서 09:00을 의미해요(겨울엔 14:00 UTC, 여름엔 13:00 UTC). - 반복 이벤트 규칙을 어떻게 평가할지:
Europe/Paris에서 09:00에 발생하는 일일 이벤트는 DST 경계를 넘어서도 로컬 시간 09:00을 유지해요.
Instant 문자열("Z"로 끝나는)의 경우 timezone 필드는 start/end를 어떻게 해석할지에 영향을 주지 않아요. 이미 절대적인 시점이기 때문이죠.
하지만 반복 이벤트 계산에는 여전히 사용돼요.
:::success
timezone이 설정되지 않으면 컴포넌트는 날짜 라이브러리의 기본 타임존을 사용해요.
:::
렌더링 동작
displayTimezone prop은 모든 이벤트를 UI에서 어떻게 렌더링할지 제어해요.
displayTimezone을 바꾸는 것은 시각적 표현에만 영향을 미쳐요.
이벤트 데이터를 수정하거나 이벤트가 발생하는 시점을 바꾸지는 않아요.
<EventCalendar
// ...other props
displayTimezone="Europe/Paris"
/>
import * as React from 'react';
import { EventCalendar } from '@mui/x-scheduler/event-calendar';
import {
defaultVisibleDate,
initialEvents,
resources,
} from '../datasets/timezone-community-instant-based';
export default function TimezoneInstantBased() {
const [events, setEvents] = React.useState(initialEvents);
return (
<div style={{ height: '600px', width: '100%' }}>
<EventCalendar
events={events}
resources={resources}
defaultVisibleDate={defaultVisibleDate}
onEventsChange={setEvents}
defaultPreferences={{ isSidePanelOpen: false }}
displayTimezone="Europe/Paris"
/>
</div>
);
}
지원되는 타임존
displayTimezone prop과 이벤트의 timezone 필드 모두 다음 값을 받아요:
| 타임존 | 설명 |
|---|---|
"UTC" |
협정 세계시(Coordinated Universal Time)를 사용해요 |
"default" |
날짜 라이브러리의 기본 타임존을 사용해요 |
"system" |
시스템의 로컬 타임존을 사용해요 |
| IANA 표준 존 | IANA 타임존이면 아무거나, 예: "Europe/Paris" 또는 "America/New_York". 전체 목록 |
이벤트 만들기
UI에서 이벤트를 만들 때, 입력한 날짜/시간은 현재 displayTimezone에서 해석돼요.
생성된 이벤트에는 명시적인 timezone 필드가 포함되지 않아요.
결과적으로 이벤트가 처리될 때 원래 타임존은 "default"로 취급돼요.
반복 이벤트와 타임존
반복 이벤트는 특정 타임존에서 평가되는 패턴을 정의해요.
예를 들어 Europe/Paris 타임존에서 매일 09:00에 발생하는 일일 반복 이벤트를 생각해볼게요:
const event = {
id: '1',
title: 'Daily standup',
start: '2024-03-01T08:00:00Z', // 파리에서 09:00 (겨울엔 UTC+1)
end: '2024-03-01T09:00:00Z',
timezone: 'Europe/Paris',
rrule: 'FREQ=DAILY',
};
일광 절약 시간제가 시작되어도(2024년 3월 31일) 이벤트는 Europe/Paris에서 로컬 시간 09:00에 계속 발생해요.
Scheduler는 이벤트의 timezone을 사용해 DST 경계를 넘어서도 반복 패턴을 올바르게 해석하고 확장해요.
이벤트 다이얼로그도 이벤트의 timezone에서 반복 규칙을 읽고 써요. 제공하는 요일·일자와 "Until" 일자는 해당 타임존에서의 이벤트 기준이며, 발생이 표시되는 날짜와 다를 수 있어요.
이벤트의 타임존이 displayTimezone과 다르면 Recurrence 탭의 반복 선택기 아래에 "Timezone: …" 메모가 표시되고, 읽기 전용 세부 정보는 반복 라벨에 타임존 이름을 덧붙여요.
UI에서 만들어진 이벤트에는 timezone 필드가 없으므로, 캘린더가 다른 타임존을 표시할 때 메모는 시스템 타임존(default 것)을 가리켜요.
import * as React from 'react';
import { EventCalendarPremium } from '@mui/x-scheduler-premium/event-calendar-premium';
import {
defaultVisibleDate,
initialEvents,
resources,
} from '../datasets/timezone-instant-based-events';
export default function TimezoneRecurringEvents() {
const [events, setEvents] = React.useState(initialEvents);
return (
<div style={{ height: '600px', width: '100%' }}>
<EventCalendarPremium
events={events}
resources={resources}
defaultVisibleDate={defaultVisibleDate}
onEventsChange={setEvents}
defaultPreferences={{ isSidePanelOpen: false }}
viewConfig={{
week: { initialScrollTime: 0 },
day: { initialScrollTime: 0 },
}}
displayTimezone="Europe/Paris"
/>
</div>
);
}