-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
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’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[pickers] Cannot pass options to the customParseFormat
dayjs plugin
#11148
Comments
Hey @n0rb |
One solution would be to move our But that is a breaking change because people could rely on the existence of this plugin before any component is rendered. |
Yes. That's basically what I was investigating just now as well. I did also try to find a way if you can add the option after extending, but that does not seem possible |
Interestingly enough we don't need that check before the call to
So if the plugin has already been applied it will just return the instance without doing anything on it. So we can safely call |
customParseFormat
dayjs plugin
Steps to reproduce
Steps:
<LocalizationProvider dateAdapter={AdapterDayjs}>
3.test the override somewhere in your app below the LocalizationProvider:
Current behavior
the test will output
1998-04-25
Expected behavior
it should output
1898-04-25
due to parseTwoDigitYear override
Context
my customer needs custom parsing of two digit year inputs. ie all two digit inputs should be parsed to 1800s
this can be established with dayjs customParseFormat Plugin and parseTwoDigitYear Function override
iamkun/dayjs#1418
iamkun/dayjs#1421
(the default behavior of dayjs with two digit years is
however when using AdapterDayjs it already extends Dayjs at line 18 https://github.com/mui/mui-x/blob/master/packages/x-date-pickers/src/AdapterDayjs/AdapterDayjs.ts
dayjs does not seem to allow extending again with customParseFormat plugin and setting parseTwoDigitYear is ignored
Your environment
npx @mui/envinfo
Search keywords: AdapterDayjs parseTwoDigitYear customParseFormat
The text was updated successfully, but these errors were encountered: