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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[pickers] BuddhistEra support #9784

Open
2 tasks done
eikqzx opened this issue Jul 25, 2023 · 14 comments
Open
2 tasks done

[pickers] BuddhistEra support #9784

eikqzx opened this issue Jul 25, 2023 · 14 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it feature: Keyboard editing Related to the pickers keyboard edition

Comments

@eikqzx
Copy link

eikqzx commented Jul 25, 2023

Duplicates

  • I have searched the existing issues

Latest version

  • I have tested the latest version

Summary 💡

original Dayjs is support BuddhistEra why AdapterDayjs in mui is not support?

Examples 🌈

No response

Motivation 🔦

in original Dayjs is just
" import buddhistEra from 'dayjs/plugin/buddhistEra';
dayjs.extend(buddhistEra);
dayjs().format("DD MM BBBB") "
it return "25 7 2563"
and I try to format props in component DatePicker it return "25 7 BBBB"

Order ID 💳 (optional)

No response

@eikqzx eikqzx added the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Jul 25, 2023
@noraleonte noraleonte changed the title BuddhistEra support [pickers] BuddhistEra support Jul 25, 2023
@noraleonte noraleonte added the component: pickers This is the name of the generic UI component, not the React module! label Jul 25, 2023
@noraleonte
Copy link
Contributor

Thanks for raising this issue! 🙌

Could you provide a reproduction case? Maybe a codesandbox with what you are trying to achieve? I feel like the problem might be because you are trying to use 'BBBB' as the format for the year. You can check out the formats we support here

@noraleonte noraleonte added status: waiting for author Issue with insufficient information and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Jul 25, 2023
@eikqzx
Copy link
Author

eikqzx commented Jul 25, 2023

https://codesandbox.io/embed/competent-paper-m4fffv?fontsize=14&hidenavigation=1&theme=dark
this it work on old versions but try to do in latest versions on mui-x/date-picker but it not work

@github-actions github-actions bot removed the status: waiting for author Issue with insufficient information label Jul 25, 2023
@noraleonte
Copy link
Contributor

We currently do not support BBBB as a valid format. While we will bring this up within the team, maybe doing it like this will help?

@eikqzx
Copy link
Author

eikqzx commented Jul 25, 2023

Finally! I can make it work!! this just change if (format === "YYYY") { format = "BBBB"; } to let newFormat = format.replace(/\bYYYY\b/g, "BBBB"); and return it thank for your help!

@eikqzx eikqzx closed this as completed Jul 25, 2023
@LukasTy
Copy link
Member

LukasTy commented Jul 26, 2023

@eikqzx I've tried looking for a more proper solution for this question and I think that this codesandbox does showcase a less error-prone solution.
The only issue I see is that to achieve it, we need to copy-paste and change the formatTokenMap instead of just being able to override it (like we can and did with dateFormats) or at least having it exported to be able to reuse it only changing what's needed. 🤔
What do you think? Does it serve your purpose and everything seems to work?

@eikqzx
Copy link
Author

eikqzx commented Jul 26, 2023

@eikqzx I've tried looking for a more proper solution for this question and I think that this codesandbox does showcase a less error-prone solution. The only issue I see is that to achieve it, we need to copy-paste and change the formatTokenMap instead of just being able to override it (like we can and did with dateFormats) or at least having it exported to be able to reuse it only changing what's needed. 🤔 What do you think? Does it serve your purpose, and everything seems to work?

Yes, thank for you improve code.

@LukasTy
Copy link
Member

LukasTy commented Jul 26, 2023

Reopening the issue.
We'll discuss the best possible improvement for such cases. 👌

@LukasTy LukasTy reopened this Jul 26, 2023
@LukasTy LukasTy added the enhancement This is not a bug, nor a new feature label Jul 26, 2023
@flaviendelangle
Copy link
Member

Unfortunately we won't be able to support BBBB (and BB) because the dayjs plugin only implements formatting and we also need parsing in order to support a token.

See the plugin codebase

If you have the time to implement the parsing of BBBB (and BB) tokens, we will be happy to register them as valid tokens on our components 👍

@flaviendelangle flaviendelangle added external dependency Blocked by external dependency, we can’t do anything about it feature: Keyboard editing Related to the pickers keyboard edition and removed enhancement This is not a bug, nor a new feature labels Jul 27, 2023
@dreamo101
Copy link

dreamo101 commented Nov 27, 2024

Thank, everyone! I've been searching for a solution for a long time, and I finally found it! 👍

@eikqzx eikqzx closed this as completed Nov 28, 2024
Copy link

This issue has been closed. If you have a similar problem but not exactly the same, please open a new issue.
Now, if you have additional information related to this issue or things that could help future readers, feel free to leave a comment.

Note

@eikqzx How did we do? Your experience with our support team matters to us. If you have a moment, please share your thoughts in this short Support Satisfaction survey.

@eikqzx
Copy link
Author

eikqzx commented Nov 28, 2024

Unfortunately we won't be able to support BBBB (and BB) because the dayjs plugin only implements formatting and we also need parsing in order to support a token.

See the plugin codebase

If you have the time to implement the parsing of BBBB (and BB) tokens, we will be happy to register them as valid tokens on our components 👍

I just have time to start implementing this, but I’ve never developed a library before. Could you guide me on how to get started?

@eikqzx eikqzx reopened this Nov 28, 2024
@mike-kaonashi
Copy link

Finally! I can make it work!! this just change if (format === "YYYY") { format = "BBBB"; } to let newFormat = format.replace(/\bYYYY\b/g, "BBBB"); and return it thank for your help!

I tried to apply this way but it does not seem to work on MUIv6

@flaviendelangle
Copy link
Member

See #9784 (comment) for the reason 👍

@flaviendelangle
Copy link
Member

I just have time to start implementing this, but I’ve never developed a library before. Could you guide me on how to get started?

@eikqzx you have a look at the contributor guide of dayjs.
Then, the plugin to improve is here.
I don't know what it would require to allow the parsing of these new tokens. The dayjs owner could probably answer some of your questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! external dependency Blocked by external dependency, we can’t do anything about it feature: Keyboard editing Related to the pickers keyboard edition
Projects
None yet
Development

No branches or pull requests

6 participants