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] Fix DigitalClock time options on a DST switch day #10793

Merged
merged 11 commits into from
Oct 24, 2024

Conversation

LukasTy
Copy link
Member

@LukasTy LukasTy commented Oct 24, 2023

Fixes #10783

Change DigitalClock time options building to use startOfYear to avoid DST issues.
After some exploration, I decided to go with a solution proposed here: #10783 (comment).
In this way we are not fighting to not have duplicate time options as they technically make sense, we only ensure that options for the whole day are included (not limiting options to 24 hours * minutesStep)

@LukasTy LukasTy added bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! component: TimePicker The React component. time-zone Issues about time zone management labels Oct 24, 2023
@LukasTy LukasTy self-assigned this Oct 24, 2023
@michelengelen michelengelen changed the base branch from master to next November 6, 2023 14:20
Copy link

github-actions bot commented Nov 9, 2023

This pull request has conflicts, please resolve those before we can evaluate the pull request.

@github-actions github-actions bot added the PR: out-of-date The pull request has merge conflicts and can't be merged label Nov 9, 2023
@@ -124,6 +124,21 @@ export const mergeDateAndTime = <TDate>(
return mergedDate;
};

export const isEqualTime = <TDate>(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am afraid this is risky if we support ms one day.
Can the ms be different? If not we could check them as well

@flaviendelangle
Copy link
Member

@LukasTy what is the current status of this PR?

@LukasTy
Copy link
Member Author

LukasTy commented Jan 8, 2024

what is the current status of this PR?

I shelved it while tackling more pressing matters.
Will get back to re-testing and finalizing it this week. 😉

@LukasTy LukasTy changed the base branch from next to master October 22, 2024 11:35
@github-actions github-actions bot removed the PR: out-of-date The pull request has merge conflicts and can't be merged label Oct 22, 2024
@mui mui deleted a comment from mui-bot Oct 22, 2024
@mui-bot
Copy link

mui-bot commented Oct 23, 2024

Deploy preview: https://deploy-preview-10793--material-ui-x.netlify.app/

Generated by 🚫 dangerJS against ab4819f

@LukasTy LukasTy changed the title [pickers] Fix DigitalClock DST related problem [pickers] Fix DigitalClock time options on a DST switch day Oct 24, 2024
return (
<ClockItem
key={formattedValue}
key={`${option.valueOf()}-${formattedValue}`}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only using option.valueOf() fails on AdapterDayjs as it handles DST in a strange manner—they don't have duplicate options for the same hour, they format the duplicate offset time differently, but that's why we need to include the formattedValue in the key to ensure uniqueness. 🙈
Screenshot 2024-10-24 at 12 01 22

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 That is weird indeed

We could also format with the day I guess, but it's probably not worth the computation time that is higher than .valueOf +a formatted value that we are also using elsewhere.

@LukasTy
Copy link
Member Author

LukasTy commented Oct 24, 2024

I have updated the PR/solution and description with some extra notes.

@LukasTy LukasTy added the needs cherry-pick The PR should be cherry-picked to master after merge label Oct 24, 2024
Copy link
Member

@flaviendelangle flaviendelangle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The fix make sense to me

Thanks for taking care of it 🙏

return (
<ClockItem
key={formattedValue}
key={`${option.valueOf()}-${formattedValue}`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 That is weird indeed

We could also format with the day I guess, but it's probably not worth the computation time that is higher than .valueOf +a formatted value that we are also using elsewhere.

@LukasTy LukasTy merged commit 103c59c into mui:master Oct 24, 2024
24 checks passed
@LukasTy LukasTy deleted the fix-digital-clock-dst-reliance branch October 24, 2024 12:14
LukasTy added a commit to LukasTy/mui-x that referenced this pull request Oct 24, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something doesn't work component: pickers This is the name of the generic UI component, not the React module! component: TimePicker The React component. needs cherry-pick The PR should be cherry-picked to master after merge time-zone Issues about time zone management v6.x v7.x
Projects
None yet
3 participants