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

[pickers] Add Support for displaying Julian Date on Date Picker #15023

Open
AnthonyLaurio opened this issue Oct 18, 2024 · 6 comments
Open

[pickers] Add Support for displaying Julian Date on Date Picker #15023

AnthonyLaurio opened this issue Oct 18, 2024 · 6 comments
Labels
component: pickers This is the name of the generic UI component, not the React module! feature: Keyboard editing Related to the pickers keyboard edition new feature New feature or request

Comments

@AnthonyLaurio
Copy link

AnthonyLaurio commented Oct 18, 2024

Summary

Currently when displaying the date using the Date Picker component there is no way to display the current day of the year (Julian Date). Previously in MUI Labs v5 you could use inputFormat: "DDD" to display the day of the year. This does not seem to be supported in MUI-X 7 Date Pickers as the same format string now displays the day of the month twice. We are using the Localization Provider with the Moment Adapter.

Examples

https://mui.com/x/react-date-pickers/adapters-locale/

<DateField
label="Date Field"
format="MM - DD - YYYY [DDD]"
defaultValue={dayjs('2022-04-17')}
/>
Should display: "04 - 17 - 2022 [107]"
Actual display: "04 - 17 - 2022 [1717]"

Motivation

I work in an industry that utilizes the day of the year (JDate) for standardization across teams which makes it important to be able to easily reference it when selecting a date. This is a feature that already exists in our date pickers being used by our users and would require us to develop a custom work around to upgrade from MUI Labs 5 to MUI X 7.

Search keywords: Support, JDate, Julian Date, J Date, Date Picker, MUIX, MUI-X, Add, Feature

@AnthonyLaurio AnthonyLaurio added new feature New feature or request status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 18, 2024
@alexfauquette
Copy link
Member

The 1717 is because our format parser only knows D and DD tokens, so it translate DDD as a token of DD next to a token D.

To clarify, is the [DDD] section supposed to be editable?

@LukasTy
Copy link
Member

LukasTy commented Oct 21, 2024

@AnthonyLaurio, could you clarify Alex's editing question? 🤔
We support a subset of format elements because each of them has to play with the custom field component that we are using.
The day of the year section can't easily work with other sections because we are not changing other sections than the one you are currently editing, this means that editing a day would not change the day of the year.

If you don't need that specific section editable, have you considered passing it in as an adornment?
Here is a demo doing just that.

@LukasTy LukasTy added status: waiting for author Issue with insufficient information component: pickers This is the name of the generic UI component, not the React module! and removed status: waiting for maintainer These issues haven't been looked at yet by a maintainer labels Oct 21, 2024
@LukasTy LukasTy changed the title Add Support for displaying Julian Date on Date Picker [pickers] Add Support for displaying Julian Date on Date Picker Oct 21, 2024
@LukasTy LukasTy added the feature: Keyboard editing Related to the pickers keyboard edition label Oct 21, 2024
@AnthonyLaurio
Copy link
Author

AnthonyLaurio commented Oct 21, 2024

The 1717 is because our format parser only knows D and DD tokens, so it translate DDD as a token of DD next to a token D.

To clarify, is the [DDD] section supposed to be editable?

Apologies for the confusion. No, the [DDD] section does not need to be editable. It should just be if I select a date with the DatePicker it should then display both the regular date and the JDate/day of the year in the date field.

@LukasTy I have not tried the adornement route! I'll check that out as it might fill our need for now. I brought this up because DDD in the format string works with our current DatePicker using MUI Labs 5.X.X but when we swap it out with the date picker from MUI X 7 it no longer works. Wasn't sure if this was something that just wasn't supported yet and is in the works or if the token had changed since labs and I just couldn't find the right one since MUI X seems to be the successor to MUI Labs.

Thank you both for your responses!

@github-actions github-actions bot added status: waiting for maintainer These issues haven't been looked at yet by a maintainer and removed status: waiting for author Issue with insufficient information labels Oct 21, 2024
@LukasTy
Copy link
Member

LukasTy commented Oct 21, 2024

I brought this up because DDD in the format string works with our current DatePicker using MUI Labs 5.X.X but when we swap it out with the date picker from MUI X 7 it no longer works. Wasn't sure if this was something that just wasn't supported yet and is in the works or if the token had changed since labs and I just couldn't find the right one since MUI X seems to be the successor to MUI Labs.

On v6 of @mui/x-date-pickers we have introduced the notion of field components which are the evolution of the input element for date entry.
It's one step closer to being closer implementation-wise to the native date input.
This implementation requires way more custom handling, thus we have narrowed down the most popular tokens/formats that we support for now.
Any new token support needs consideration.

@AnthonyLaurio
Copy link
Author

I brought this up because DDD in the format string works with our current DatePicker using MUI Labs 5.X.X but when we swap it out with the date picker from MUI X 7 it no longer works. Wasn't sure if this was something that just wasn't supported yet and is in the works or if the token had changed since labs and I just couldn't find the right one since MUI X seems to be the successor to MUI Labs.

On v6 of @mui/x-date-pickers we have introduced the notion of field components which are the evolution of the input element for date entry. It's one step closer to being closer implementation-wise to the native date input. This implementation requires way more custom handling, thus we have narrowed down the most popular tokens/formats that we support for now. Any new token support needs consideration.

Thank you for the explanation! I will push forward with the work around solution and humbly request your consideration in adding day of the year to the support date format tokens🙏🏻 Thank you again for taking the time to respond!

@LukasTy LukasTy removed the status: waiting for maintainer These issues haven't been looked at yet by a maintainer label Oct 22, 2024
@flaviendelangle
Copy link
Member

No, the [DDD] section does not need to be editable.

When we have some bandwidth, I really think we should add support for those read-only section.
They would be a lot easier to implement than a full support of new section types with editing.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
component: pickers This is the name of the generic UI component, not the React module! feature: Keyboard editing Related to the pickers keyboard edition new feature New feature or request
Projects
None yet
Development

No branches or pull requests

4 participants