Skip to content

Conversation

flaviendelangle
Copy link
Member

Backport from the Base UI version of the adapter.

@flaviendelangle flaviendelangle self-assigned this Aug 18, 2025
@flaviendelangle flaviendelangle added type: bug It doesn't behave as expected. scope: pickers Changes related to the date/time pickers. scope: scheduler Changes related to the scheduler. labels Aug 18, 2025
@mui-bot
Copy link

mui-bot commented Aug 18, 2025

Deploy preview: https://deploy-preview-19230--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%) 🔺+2B(0.00%)
@mui/x-data-grid-premium 0B(0.00%) 🔺+2B(0.00%)
@mui/x-charts 0B(0.00%) 0B(0.00%)
@mui/x-charts-pro 0B(0.00%) 🔺+2B(0.00%)
@mui/x-date-pickers 0B(0.00%) 0B(0.00%)
@mui/x-date-pickers-pro 0B(0.00%) 🔺+4B(0.00%)
@mui/x-tree-view 0B(0.00%) 0B(0.00%)
@mui/x-tree-view-pro 0B(0.00%) 🔺+1B(0.00%)

Details of bundle changes

Generated by 🚫 dangerJS against a39a5e1


export function isWeekend(adapter: Adapter, value: SchedulerValidDate): boolean {
const dayOfWeek = adapter.getDayOfWeek(value);
const sunday = adapter.format(adapter.date('2025-08-09'), 'weekday');
Copy link
Member Author

Choose a reason for hiding this comment

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

I'm struggling to find a better way to detect the week end 😬
I'm not even sure if some adapter have a locale-based notion of "Week end".

Copy link
Member

Choose a reason for hiding this comment

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

Neat trick! 👀

Copy link
Member

Choose a reason for hiding this comment

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

But the weekend might not be on Saturday and Sunday for every locale. 🤔
Doesn't US technically have the weekend on Sunday and Monday?

Copy link
Member

Choose a reason for hiding this comment

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

Scratch that previous question part.
Regardless, based on ChatGPT information, some countries do have weekends on different days:
Screenshot 2025-08-19 at 16 17 49

Copy link
Member Author

Choose a reason for hiding this comment

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

Doesn't US technically have the weekend on Sunday and Monday?

No, the week start on Sunday, but the week end is still Sartuday and Sunday AFAIK.
Those are two distinct concepts, sadly enough we don't use "week-end" to mean the end of the week 👨 🔫 . So for me the behavior of the Scheduler before this PR was already broken, probably even more than after the PR.

With that being said, I'm not surprised that not all country and culture have Saturday + Sunday as week end. Bryntum has a concept of working days (that user can define manually) which is probably what you want in a lot of scenarios (to include public holdays for example). But I'm not sure it's always what we want and I'm wondering if there is a disctinct concept of week end.
It seems that Bryntum uses there concept of "non working days" for the equivalent of the UI we built. BUT at the same time they have a class specific to week end that apply to Saturday and Sunday (they don't implement the nuance Chat GPT gave, or at least it's not documented).

image image

TLDR: It's a mess and I think starting with the current approach and then research how to best introduce a notion of working / non-working days is fine.

Copy link
Member

@LukasTy LukasTy Aug 19, 2025

Choose a reason for hiding this comment

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

WDYT about adding a isWeekend method to the adapter?
Looks like Luxon and date-fns have the means to resolve this, whereas for others we can use getWeekInfo as a basis and fallback to your solution if weekInfo is not available (i.e. Firefox).

Copy link
Member Author

Choose a reason for hiding this comment

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

It would probably be the right solution.
I think we can add it to the Base UI version and keep it hardcoded for now in the Scheduler while we use a copy paste of the MUI X adapters (I'd like to avoid having 3 versions of the adapter to maintain 😆 )

Copy link
Member

Choose a reason for hiding this comment

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

Yeah, the notion of work days is probably the best shot at being the silver bullet for the Scheduler's case. 👌
I agree with your proposal. 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

To summarize:

  1. Hardcode Saturday and Sunday in the Scheduler for now
  2. Add a isWeekend method on the Base UI adapters
  3. When the Scheduler starts using the Base UI adapters, remove the hardcoded days and use the method instead
  4. When we introduce a notion of working / non-working days, set the default value to equal the week end days (using isWeekEnd).

@flaviendelangle flaviendelangle marked this pull request as ready for review August 18, 2025 16:02
@flaviendelangle flaviendelangle added type: bug It doesn't behave as expected. and removed type: bug It doesn't behave as expected. scope: scheduler Changes related to the scheduler. labels Aug 19, 2025
Copy link
Member

@rita-codes rita-codes left a comment

Choose a reason for hiding this comment

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

Thanks for taking care of this!

@flaviendelangle flaviendelangle merged commit 1ea5c80 into mui:master Aug 21, 2025
23 checks passed
@flaviendelangle flaviendelangle deleted the locale-week-day branch August 21, 2025 06:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
scope: pickers Changes related to the date/time pickers. type: bug It doesn't behave as expected.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants