-
-
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
[DateTimeRangePicker] Fix date format resolving from views on 24hr locales #14341
[DateTimeRangePicker] Fix date format resolving from views on 24hr locales #14341
Conversation
Deploy preview: https://deploy-preview-14341--material-ui-x.netlify.app/ |
0dbc59a
to
dbddcbf
Compare
DateTimePickers
DateTimeRangePickers
DateTimeRangePickers
DateTimeRangePickers
DateTimeRangePickers
DateTimeRangePickers
@@ -30,7 +35,7 @@ export const resolveDateTimeFormat = <TDate extends PickerValidDate>( | |||
views.forEach((view) => { | |||
if (isTimeView(view)) { | |||
timeViews.push(view as TimeView); | |||
} else { | |||
} else if (isDatePickerView(view)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The problem was an oversight that we did not exclude meridiem
view, which caused resolveDateFormat
to always return keyboardDate
in case of a locale with 12h clock.
On 24h clock the behavior was "correct".
I've adjusted the code to avoid this inconsistency and also added an exception to not resolve dateFormat
on DateTimeRange
pickers as they do not have different date
views other than day
for now.
DateTimeRangePickers
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've adjusted the approach to one that looks more correct to me.
I'm not sure why we would have differentiated the behavior based on the presence of value
. 🤔
Let me know what you think about the solution. 😉
I assumed that veryfing if the value is an array (date range) would be more clear than adding a new parameter to the function to be used only in DateTimePickers, since the view verification was done in |
Fixes #14334.
For
DateTimeRangePickers
the ["day"] case returns an incorrect format.