Skip to content

fix(ui): Calendar view respects user-selected timezone - #67497

Merged
pierrejeambrun merged 2 commits into
apache:mainfrom
anmolxlight:fix/calendar-view-timezone-67477
Jun 3, 2026
Merged

fix(ui): Calendar view respects user-selected timezone#67497
pierrejeambrun merged 2 commits into
apache:mainfrom
anmolxlight:fix/calendar-view-timezone-67477

Conversation

@anmolxlight

Copy link
Copy Markdown
Contributor

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 groupingcreateDailyDataMap and createHourlyDataMap used run.date.slice(0, 10) / run.date.slice(0, 13) to extract date/hour, ignoring the user's timezone
  3. Grid constructiongenerateDailyCalendarData 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

Thread selectedTimezone from useTimezone() through the Calendar
component tree. Compute date ranges in the selected timezone before
converting to UTC for API queries. Group Dag runs by their local
date/hour in the selected timezone instead of raw UTC string slicing.

Fixes apache#67477
@boring-cyborg boring-cyborg Bot added the area:UI Related to UI/UX. For Frontend Developers. label May 25, 2026
@bbovenzi bbovenzi marked this as a duplicate of #67539 May 26, 2026
@bbovenzi bbovenzi closed this May 26, 2026
@bbovenzi bbovenzi reopened this May 26, 2026

@choo121600 choo121600 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The static checks seem to be failing. Could you check it once?

@anmolxlight

Copy link
Copy Markdown
Contributor Author

the rule requires max 3 params — adding timezone as a positional arg pushed generateHourlyCalendarData, calculateDataBounds, and createCalendarScale over the limit. fixed by refactoring each to use a single options object for config params. eslint/prettier/tsc all pass now.

@anmolxlight

Copy link
Copy Markdown
Contributor Author

the @typescript-eslint/max-params rule requires max 3 params — adding timezone as a positional arg pushed generateHourlyCalendarData, calculateDataBounds, and createCalendarScale over the limit. fixed by refactoring each to use a single options object for config params. eslint/prettier/tsc all pass now.

@potiuk potiuk added the ready for maintainer review Set after triaging when all criteria pass. label May 27, 2026

@pierrejeambrun pierrejeambrun left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, tested and working as expected.

@pierrejeambrun pierrejeambrun added this to the Airflow 3.2.3 milestone Jun 3, 2026
@pierrejeambrun
pierrejeambrun merged commit 7d66aa7 into apache:main Jun 3, 2026
83 checks passed
@github-actions

github-actions Bot commented Jun 3, 2026

Copy link
Copy Markdown
Contributor

Backport successfully created: v3-2-test

Note: As of Merging PRs targeted for Airflow 3.X
the committer who merges the PR is responsible for backporting the PRs that are bug fixes (generally speaking) to the maintenance branches.

In matter of doubt please ask in #release-management Slack channel.

Status Branch Result
v3-2-test PR Link

pierrejeambrun pushed a commit that referenced this pull request Jun 3, 2026
…67497) (#67954)

* fix(ui): make Calendar view respect user-selected timezone

Thread selectedTimezone from useTimezone() through the Calendar
component tree. Compute date ranges in the selected timezone before
converting to UTC for API queries. Group Dag runs by their local
date/hour in the selected timezone instead of raw UTC string slicing.

Fixes #67477

* fix: refactor calendarUtils params to options objects to satisfy @typescript-eslint/max-params

---------
(cherry picked from commit 7d66aa7)

Co-authored-by: Anmol Mishra <anmolxlight@gmail.com>
Co-authored-by: Anmol Mishra <anmolx.work@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area:UI Related to UI/UX. For Frontend Developers. ready for maintainer review Set after triaging when all criteria pass.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Calendar view does not respect user-selected timezone

6 participants