Skip to content

Conversation

@rita-codes
Copy link
Member

@rita-codes rita-codes commented Nov 20, 2025

Issue #20390

In this PR:

  • Located nowUpdatedEveryMinute and any selector that generates “now”, “today”, or visible ranges.
  • Made these selectors use the render timezone and the adapter to create dates in the render timezone.
  • Factored out any duplicate logic into a shared utils
  • Added tests ensuring behavior stays the same for 'default' and changes appropriately when passing a specific timezone.

@rita-codes rita-codes self-assigned this Nov 20, 2025
@rita-codes rita-codes added type: new feature Expand the scope of the product to solve a new problem. scope: scheduler Changes related to the scheduler. labels Nov 20, 2025
…r-timezone-in-nowupdatedeveryminute-and-date-generating-selectors
@mui-bot
Copy link

mui-bot commented Nov 20, 2025

Deploy preview: https://deploy-preview-20411--material-ui-x.netlify.app/

Bundle size report

Bundle Parsed size Gzip size
@mui/x-data-grid 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-pro 0B(0.00%) 0B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 0B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 0B(0.00%)
@mui/x-charts-premium 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 0B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 0B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against e08db6e


const expected = adapter.startOfDay(adapter.now(timezone));

expect(store.state.visibleDate).toEqualDateTime(expected);
Copy link
Member Author

Choose a reason for hiding this comment

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

Since we're talking about "visibleDate" I think it makes sense to pass the rendered timezone to the callback here

Copy link
Member

Choose a reason for hiding this comment

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

To which callback? siblingVisibleDateGetter?

Copy link
Member Author

Choose a reason for hiding this comment

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

sorry, the comment should be a couple of lines below, I meant the value for onVisibleDateChange

Copy link
Member

Choose a reason for hiding this comment

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

Could you give a code snippet with your proposal?
I'm not sure to understand.

Copy link
Member Author

Choose a reason for hiding this comment

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

Sorry I didn't explain the "problem" properly 😂
We were talking about how we should handle dates "inside" and "outside" the component. As a general rule, we are treating all dates "inside" our app with the render timezone, but when we need to send that data outside, the data is going back to the user again (updates, onEventChange, etc) all the dates should be in the original timezone. That makes sense but there is an exception here, and that's onVisibleDateChange.
Even if we're returning data to the user, the information is "what's the visible date" for the final user, for the user that is using the app, and that user is seeing a date in a specific timezone, so I think we should send the date with the render timezone in onVisibleDateChange.
does this make sense to you too? 🤔

Copy link
Member

Choose a reason for hiding this comment

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

People can still provide visibleDate in another timezone, so we need to make sure it's properly converted (in the selector I'd say, better keep the state equal to the controlled prop whenever possible. And always use the selector is a good practice).

For the onVisibleDateChange, we can keep the UI timezone. To be honest I don't know what's better. I agree with your argument, but at the same time it's not super satisfying to pass a value in another TZ than the one we were given for the previous value.

Copy link
Member Author

@rita-codes rita-codes Nov 24, 2025

Choose a reason for hiding this comment

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

I think we're fully aligned then.

For controlled mode, it makes sense to keep visibleDate exactly as provided, without applying any timezone logic to it. The component should treat the user-provided value as the source of truth, and any timezone normalization should only happen in the selector purely for rendering purposes. That way the value isn't modified, and the component remains properly controlled.

About onVisibleDateChange, I think returning the date in the render timezone is the most consistent with what the end-user actually sees, but I agree it's not ideal that the input and output timezones differ. I'll take a look at how other libraries handle this and bring it to the weekly meeting so we can decide together 👀

Copy link
Member Author

@rita-codes rita-codes Nov 25, 2025

Choose a reason for hiding this comment

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

I documented my research here, including how FullCalendar and Bryntum handle it and why the render-timezone value is the most consistent choice for onVisibleDateChange (for "UI callbacks" in general)

So I think we should follow that path: keep the controlled visibleDate untouched, do any normalization only in the selector, emit the render-timezone value for UI callbacks (onVisibleDateChange) since that’s what the final user actually sees, and as for saving/updating convert back to the original timezone (like Bryntum does).

@rita-codes rita-codes changed the title [scheduler] Timezone issue 2: use render timezone in nowUpdatedEveryMinute and date generating selectors [scheduler] Timezone issue 2: use render timezone in nowUpdatedEveryMinute and date generating selectors Nov 20, 2025
rita-codes and others added 5 commits November 20, 2025 07:26
…r-timezone-in-nowupdatedeveryminute-and-date-generating-selectors
…imezone-issue-2-use-render-timezone-in-nowupdatedeveryminute-and-date-generating-selectors
…r-timezone-in-nowupdatedeveryminute-and-date-generating-selectors
…r-timezone-in-nowupdatedeveryminute-and-date-generating-selectors
…r-timezone-in-nowupdatedeveryminute-and-date-generating-selectors
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

scope: scheduler Changes related to the scheduler. type: new feature Expand the scope of the product to solve a new problem.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[scheduler] Timezone Issue 2: Use render timezone in nowUpdatedEveryMinute and date-generating selectors

3 participants