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

Datepicker is not using custom dateFormat from locale #42119

Open
richard-schiemenz opened this issue May 3, 2023 · 15 comments
Open

Datepicker is not using custom dateFormat from locale #42119

richard-schiemenz opened this issue May 3, 2023 · 15 comments
Assignees
Labels
🐛 Bug Ant Design Team had proved that this is a bug. Inactive

Comments

@richard-schiemenz
Copy link

Reproduction link

Edit on CodeSandbox

Steps to reproduce

Wrap DatePicker in ConfigProvider with locale and dateFormat for DatePicker set.
Select a date in the DatePicker.

What is expected?

The date is formatted with the format specified in the locale.

What is actually happening?

The date is formatted with the default format.

Environment Info
antd 5.4.6
React 9.6.2
System macOS 13.3.1
Browser Chrome 112.0.5615.137

I need to set the format of the date displayed based on the locale as I have multiple locales. I have tested modifying other values in the locale object and it worked as expected. Only modifying the dateFormat seems not to be working.
Other issues show a solution by setting the format in the DatePicker to "L" but this is a fix using moment and I want to stay with the now default dayjs.

@richard-schiemenz
Copy link
Author

I don't think this is the same issue, as there the problem lied in translating written days of the week. I had a similar issue and fixed it by importing the language files.
Here however the formatting is not applied. Which in the example doesn't use any written out weekdays but just the digits.

@BoyYangzai
Copy link
Contributor

I'm sorry I was careless

@BoyYangzai
Copy link
Contributor

@richard-schiemenz I'm sorry, but the official documentation doesn't seem to indicate that the locale={} provided by the ConfigProvider can be passed in with the dateForm parameter.

@richard-schiemenz
Copy link
Author

@BoyYangzai the official example for the DatePicker locale has it listed. locale example Further it's the only date with the same format that is displayed.
From what I understand this is the right key and once worked in a previous version. It was added here #14340. There it was used with the LocaleProvider, but this was replaced by the ConfigProvider how I used it.

@BoyYangzai
Copy link
Contributor

@richard-schiemenz
I'm sorry, I couldn't find the source code when I was looking through it before.
This may be a previous usage, I'm sorry.

@richard-schiemenz
Copy link
Author

@BoyYangzai Ok, thank you.
Maybe it should be removed from the example if it is no longer supported. As this example is linked to on the official documentation DatePicker Localization.
I updated the code sandbox to show the implementation with the locale directly input to the DatePicker as shown in the first example. It also doesn't apply the format.

@Wxh16144
Copy link
Member

Wxh16144 commented May 4, 2023

I think it is indeed a bug.

@Wxh16144 Wxh16144 added 🐛 Bug Ant Design Team had proved that this is a bug. and removed unconfirmed labels May 4, 2023
@Wxh16144 Wxh16144 self-assigned this May 4, 2023
@Wxh16144
Copy link
Member

Co-authored @any1024

@Rafael-Martins
Copy link
Contributor

Hey guys, looking at it to see it if I can contribute with a pr!

@linhf123
Copy link
Contributor

@richard-schiemenz The writing should be as follows.
image

@linhf123
Copy link
Contributor

@Rafael-Martins You are at antd 4. * Have you used this function in the version?
I tried 4. * The version was found to be ineffective, and the code of antd did not support it here.

@linhf123
Copy link
Contributor

Hey guys, looking at it to see it if I can contribute with a pr!
This is caused by the refactoring of rc-picker. If you are interested, you can contribute with a pr.

@Rafael-Martins
Copy link
Contributor

Hey guys, looking at it to see it if I can contribute with a pr!
This is caused by the refactoring of rc-picker. If you are interested, you can contribute with a pr.

Oh cool, I was fixing my local environment. I will try to fix it today!

@Rafael-Martins
Copy link
Contributor

Rafael-Martins commented May 18, 2023

I opened a pr with a solution, we can discuss about it in there!

@yoyo837
Copy link
Contributor

yoyo837 commented Oct 19, 2023

Duplicate of #23902

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐛 Bug Ant Design Team had proved that this is a bug. Inactive
Projects
None yet
Development

No branches or pull requests

6 participants