anmolxlight opened a new pull request, #67497: URL: https://github.com/apache/airflow/pull/67497
### Problem The Calendar view in the Airflow UI always shows Dag runs in UTC, ignoring the user's selected timezone from the TimezoneContext. Runs are grouped by their raw UTC date/hour via string slicing, and the calendar grid bounds are computed using the browser-local timezone. ### Root Cause The Calendar feature tree had no awareness of `useTimezone()` / `TimezoneContext`: 1. **API queries** — The date range sent to the API used `selectedDate` directly without timezone conversion 2. **Run grouping** — `createDailyDataMap` and `createHourlyDataMap` used `run.date.slice(0, 10)` / `run.date.slice(0, 13)` to extract date/hour, ignoring the user's timezone 3. **Grid construction** — `generateDailyCalendarData` and `generateHourlyCalendarData` used `dayjs().year(...)` instead of `dayjs().tz(timezone).year(...)`, computing grid bounds in browser-local time ### Changes - **`calendarUtils.ts`** — Added `dayjs/plugin/timezone` and `dayjs/plugin/utc` imports. Threaded a `timezone: string` parameter through all exported/internal functions. Replaced `run.date.slice(0, 10)` / `run.date.slice(0, 13)` with `dayjs(run.date).tz(timezone).format(...)`. Grid construction now uses `dayjs().tz(timezone)` instead of bare `dayjs()`. - **`Calendar.tsx`** — Imported `useTimezone`, added dayjs tz/utc plugins. Gets `selectedTimezone` from context. Computes `startDate`/`endDate` in the selected timezone via `selectedDate.tz(selectedTimezone, true)`, then converts to UTC with `.utc().format(...)` for API queries. Passes `timezone` prop to view components and `createCalendarScale`. - **`DailyCalendarView.tsx`** — Accepts `timezone` prop, passes it to `generateDailyCalendarData`. - **`HourlyCalendarView.tsx`** — Accepts `timezone` prop, passes it to `generateHourlyCalendarData`. - **`calendarUtils.test.ts`** — All `calculateDataBounds` and `createCalendarScale` calls updated with `"UTC"` as the 4th argument. Fixes #67477 -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
