Skip to content

Add property format to DateInput to avoid relying on locale for formatting #7150

Closed
@anarute

Description

@anarute

Provide a general summary of the feature here

Currently in order to enforce a specific date format to the DateInput and DatePicker it is needed a workaround by using a I18nProvider with a locale that suites the wanted format.

🤔 Expected Behavior?

A simpler way to pass the format to the component that is not hacky and gives more flexibility to displaying time.

😯 Current Behavior

<I18nProvider locale="zh-CN">
  <DateInput style={{ display: 'flex' }}>
    {(segment) => <DateSegment segment={segment} />}
  </DateInput>
</I18nProvider>

Which is still not great as I'm using a completely different locale in order to have a close behavior to what I need but still not good as the results is YYYY/mm/dd and not YYYY-MM-DD and also not always 2 digits in the month and day values.

💁 Possible Solution

A prop where the desired format can be passed without needing to override any locale, something like:

 <DateInput format="YYYY-MM-DD">
   {(segment) => <DateSegment segment={segment} />}
 </DateInput>

🔦 Context

The current solution is not great because the format still isn't what I need (YYYY-MM-DD) and it is a very hacky solution. Working on an international team it is important to set a common format to the calendars and not rely on users locale for that.

This is somewhat related with #3986

💻 Examples

Something similar to https://mui.com/x/react-date-pickers/adapters-locale/#custom-field-format or https://shahabyazdi.github.io/react-multi-date-picker/props/

🧢 Your Company/Team

No response

🕷 Tracking Issue

No response

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions