fix(ui): Calendar view respects user-selected timezone#67497
Open
anmolxlight wants to merge 1 commit into
Open
fix(ui): Calendar view respects user-selected timezone#67497anmolxlight wants to merge 1 commit into
anmolxlight wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:selectedDatedirectly without timezone conversioncreateDailyDataMapandcreateHourlyDataMapusedrun.date.slice(0, 10)/run.date.slice(0, 13)to extract date/hour, ignoring the user's timezonegenerateDailyCalendarDataandgenerateHourlyCalendarDatauseddayjs().year(...)instead ofdayjs().tz(timezone).year(...), computing grid bounds in browser-local timeChanges
calendarUtils.ts— Addeddayjs/plugin/timezoneanddayjs/plugin/utcimports. Threaded atimezone: stringparameter through all exported/internal functions. Replacedrun.date.slice(0, 10)/run.date.slice(0, 13)withdayjs(run.date).tz(timezone).format(...). Grid construction now usesdayjs().tz(timezone)instead of baredayjs().Calendar.tsx— ImporteduseTimezone, added dayjs tz/utc plugins. GetsselectedTimezonefrom context. ComputesstartDate/endDatein the selected timezone viaselectedDate.tz(selectedTimezone, true), then converts to UTC with.utc().format(...)for API queries. Passestimezoneprop to view components andcreateCalendarScale.DailyCalendarView.tsx— Acceptstimezoneprop, passes it togenerateDailyCalendarData.HourlyCalendarView.tsx— Acceptstimezoneprop, passes it togenerateHourlyCalendarData.calendarUtils.test.ts— AllcalculateDataBoundsandcreateCalendarScalecalls updated with"UTC"as the 4th argument.Fixes #67477