Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] Support localized start of the week on AdapterLuxon #10964

Merged
merged 13 commits into from
Nov 28, 2023

Conversation

flaviendelangle
Copy link
Member

@flaviendelangle flaviendelangle commented Nov 9, 2023

Fixes #10805

Changelog

Highlight

  • 馃殌 The Date and Time Pickers now support localized week when using AdapterLuxon.

    When using Luxon 3.4.4 or higher, the start of the week will be defined by the date locale (e.g.: Sunday for en-US, Monday for fr-FR).

Breaking changes

  • The Date and Time Pickers now use the localized week when using AdapterLuxon and Luxon v3.4.4 or higher is installed.
    This new behavior allows AdapterLuxon to have the same behavior as the other adapters.

    If you want to keep the start of the week on Monday even if your locale says otherwise, you can hardcode the week settings as follows:

    import { Settings } from 'luxon';
    
    Settings.defaultWeekSettings = {
      firstDay: 1,
      minimalDays: Info.getMinimumDaysInFirstWeek(),
      weekend: [6, 7],
    };

@flaviendelangle flaviendelangle self-assigned this Nov 9, 2023
@flaviendelangle flaviendelangle added the component: pickers This is the name of the generic UI component, not the React module! label Nov 9, 2023
@mui-bot
Copy link

mui-bot commented Nov 9, 2023

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 13, 2023
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 15, 2023
return value.startOf(
'week',
// @ts-ignore
{ useLocaleWeeks: true },
Copy link
Member Author

Choose a reason for hiding this comment

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

The types do not include the new APIs yet, I can remove those comment later.
For older versions of Luxon, this param should be ignored and the behavior should just be like before.
I think we can bump the minimal version of Luxon in v8 to unify everyones behavior, but keep supporting older one in v7 to avoid forcing a very-recent version.

Copy link
Member

@michelengelen michelengelen left a comment

Choose a reason for hiding this comment

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

just a nit ... LGTM!

Copy link
Member

@LukasTy LukasTy left a comment

Choose a reason for hiding this comment

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

Great improvement! 馃憤 馃憦

@LukasTy LukasTy added bug 馃悰 Something doesn't work enhancement This is not a bug, nor a new feature labels Nov 28, 2023
@LukasTy LukasTy changed the title [pikers] Allow to start the week on Sunday with Luxon adapter [pickers] Fix to support localized start of the week with Luxon adapter Nov 28, 2023
@flaviendelangle flaviendelangle changed the title [pickers] Fix to support localized start of the week with Luxon adapter [pickers] Support localized start of the week on AdapterLuxon Nov 28, 2023
flaviendelangle and others added 2 commits November 28, 2023 14:07
Co-authored-by: Lukas <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Co-authored-by: Michel Engelen <32863416+michelengelen@users.noreply.github.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 28, 2023
Copy link

This pull request has conflicts, please resolve those before we can evaluate the pull request.

Co-authored-by: Lukas <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
flaviendelangle and others added 3 commits November 28, 2023 14:07
Co-authored-by: Lukas <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
Co-authored-by: Lukas <llukas.tyla@gmail.com>
Signed-off-by: Flavien DELANGLE <flaviendelangle@gmail.com>
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 28, 2023
@flaviendelangle flaviendelangle merged commit 445468b into mui:next Nov 28, 2023
17 checks passed
@flaviendelangle flaviendelangle deleted the start-of-week-luxon branch November 28, 2023 13:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 馃悰 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! enhancement This is not a bug, nor a new feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[pickers] Support changing start of week day on AdapterLuxon
4 participants