Closed oliverpool closed 2 months ago
Currently the date picker always show AM/PM, which is unusual for non-english people.
Digging in the code, it seems that mui-x is using the en-US is locale is not set: https://github.com/mui/mui-x/blob/603e688d3a55740578dcd193e59063ce7bdab389/packages/x-date-pickers/src/AdapterDateFnsBase/AdapterDateFnsBase.ts#L224
en-US
locale
public is12HourCycleInCurrentLocale = () => { if (this.locale) { return /a/.test(this.locale.formatLong!.time({ width: 'short' })); } // By default, date-fns is using en-US locale with am/pm enabled return true; };
It would be nice with the locale setting could be set on date-fns: https://github.com/StaticJsCMS/static-cms/blob/9b26aff35bd00340f0e6013f744cdfc50db1e663/packages/core/src/widgets/datetime/DateTimeControl.tsx#L209
// with date-fns v2.x import locales from 'date-fns/locale'; const current_locale = locales[config.locale] ?? null; // logic could be improved? <LocalizationProvider dateAdapter={AdapterDateFns} adapterLocale={current_locale}>
I would be ready to make a PR, however I don't know:
DateTimeControl
What do you think?
Currently the date picker always show AM/PM, which is unusual for non-english people.
Digging in the code, it seems that mui-x is using the
en-US
islocale
is not set: https://github.com/mui/mui-x/blob/603e688d3a55740578dcd193e59063ce7bdab389/packages/x-date-pickers/src/AdapterDateFnsBase/AdapterDateFnsBase.ts#L224It would be nice with the
locale
setting could be set on date-fns: https://github.com/StaticJsCMS/static-cms/blob/9b26aff35bd00340f0e6013f744cdfc50db1e663/packages/core/src/widgets/datetime/DateTimeControl.tsx#L209I would be ready to make a PR, however I don't know:
locale
config value into theDateTimeControl
componentlocale
objectWhat do you think?