mui / mui-x

MUI X: Build complex and data-rich applications using a growing list of advanced React components, like the Data Grid, Date and Time Pickers, Charts, and more!
https://mui.com/x/
4.52k stars 1.31k forks source link

[pickers] Support for edge case of switching between Julian to Gregorian calendar (around 1582) #7446

Open melon opened 1 year ago

melon commented 1 year ago

Duplicates

Latest version

Steps to reproduce 🕹

Link to live example: https://mui.com/x/react-date-pickers/getting-started/

Steps:

1.choose date and view if it's correct

Current behavior 😯

1.choose date 1582/10/04, you will find it's Monday in this component, but it should be Thursday 2.dates between 1582/10/05-1582/10/14 should not exist in history (search Google for details about Gregorian Calendar and the vanishing 10 days), but in this component they exist

Expected behavior 🤔

No response

Context 🔦

No response

Your environment 🌎

npx @mui/envinfo ``` Don't forget to mention which browser you used. Output from `npx @mui/envinfo` goes here. ```
alexfauquette commented 1 year ago

Hi @melon,

What is your use case to select dates that far in the past?

Dates do not disappear. It just depends on how you count

Here is an example where days are either named according to A (starting at 0) or B (starting at 8): Let say pop wants to switch from A to B at day 4 (in naming A system).

It feels like the days between 4 and 11 (included) vanished. But they exist in calendar A and in calendar B it's just that they neither get used.

naming A 0 1 2 3 4 5 6 7 8 9
naming B 8 9 10 11 12 13 14 15 16 17
naming used 0 1 2 3 12 13 14 15 16 17

Your date library is using the Gregorian calendar for all dates (from -inifinti to +infint), so the 1582/10/14 exist. I correspond to the 1582/10/04 in the Julian calendar.

flaviendelangle commented 1 year ago

I did not find any date library supporting the Julian to Gregorian calendar jump in a smart way. If you find one, it would be interesting to see if our components are working correctly with it. But without it, we won't be able to do much.

melon commented 1 year ago

I did not find any date library supporting the Julian to Gregorian calendar jump in a smart way. If you find one, it would be interesting to see if our components are working correctly with it. But without it, we won't be able to do much.

Yes, I have to admit that it's really not necessary to choose a date that is so far from now. But as the component do allow developers to choose a date so far in the past, and the calendar gives the wrong display which could cause some misunderstanding. The better way might be 1. disallow developers to choose a date that is so far in the past, 2. fix the issue.

As for the date library, to be honest, I haven't found any javascript date library yet that handles this right. But the Calendar App on the Mac/iOS or the Calendar App on the Android do display the correct dates.

melon commented 1 year ago

Hi @melon,

What is your use case to select dates that far in the past?

Dates do not disappear. It just depends on how you count

Here is an example where days are either named according to A (starting at 0) or B (starting at 8): Let say pop wants to switch from A to B at day 4 (in naming A system).

It feels like the days between 4 and 11 (included) vanished. But they exist in calendar A and in calendar B it's just that they neither get used.

naming A 0 1 2 3 4 5 6 7 8 9 naming B 8 9 10 11 12 13 14 15 16 17 naming used 0 1 2 3 12 13 14 15 16 17 Your date library is using the Gregorian calendar for all dates (from -inifinti to +infint), so the 1582/10/14 exist. I correspond to the 1582/10/04 in the Julian calendar.

The concept of Gregorian calendar does not exist until "it was introduced in October 1582 by Pope Gregory XIII as a modification of, and replacement for, the Julian calendar"(wikipedia).