mui-x icon indicating copy to clipboard operation
mui-x copied to clipboard

[pickers][DateTimeRangePicker] Polish locale from dayjs breaks datetime format in DateTimeRangePicker since v.7.10.0

Open oskarkk opened this issue 1 year ago • 2 comments

Steps to reproduce

Link to live example: Correct in 7.9.0: https://codesandbox.io/p/sandbox/mui-daterangepicker-format-issue-7-9-0-jg2c5f Incorrect in 7.10.0: https://codesandbox.io/p/sandbox/mui-datetimerangepicker-format-issue-7-10-0-6hdc22 Incorrect in 7.14.0: https://codesandbox.io/p/sandbox/mui-datetimerangepicker-format-issue-latest-cdnst2

The issue appears when using polish locale:

      <LocalizationProvider
        dateAdapter={AdapterDayjs}
        adapterLocale={dayjs.locale("pl")}
      >
        <DateTimeRangePicker<Dayjs>
          value={[dayjs("2020-02-02T00:00:00"), dayjs("2020-02-03T00:00:00")]}
          slots={{ field: SingleInputDateTimeRangeField }}
          sx={{ "& .MuiInputBase-root": { width: "250px" } }}
        />
      </LocalizationProvider>

Current behavior

On x-date-pickers version >= 7.10.0 the picker displays date in format 02 00:00 – 03 00:00, not showing month and year.

Expected behavior

On x-date-pickers version <= 7.9.0 the picker was working correctly displaying format: 02.02.2020 00:00 – 03.02.2020 00:00

Context

No response

Your environment

Version that works: "dayjs": "1.11.13", "@mui/material": "5.16.7", "@mui/x-date-pickers-pro": "7.9.0"

Version that doesn't work: "dayjs": "1.11.13", "@mui/material": "5.16.7", "@mui/x-date-pickers-pro": "7.10.0"

Search keywords: locale, dayjs Order ID: Order 80141

oskarkk avatar Aug 25 '24 22:08 oskarkk

Hello @oskarkk,

Thanks for reporting it and providing complete information and examples. I can confirm it is a bug, probably coming from #13743 We will investigate the solution and try to push a fix as soon as possible.

arthurbalduini avatar Aug 26 '24 09:08 arthurbalduini

While we work on the fix, attributing the format prop perhaps works for you as a workaround:

<DateTimeRangePicker<Dayjs>
    value={[dayjs("2020-02-02T00:00:00"), dayjs("2020-02-03T00:00:00")]}
    format="DD/MM/YYYY HH:mm"
    slots={{ field: SingleInputDateTimeRangeField }}
    sx={{ "& .MuiInputBase-root": { width: "250px" } }}
/>

arthurbalduini avatar Aug 26 '24 10:08 arthurbalduini

:warning: 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.

@oskarkk: 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.

github-actions[bot] avatar Aug 29 '24 11:08 github-actions[bot]