Normalize milliseconds in picked dateTime in DateTimePicker to 0 #7328
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Normalize milliseconds in picked
dateTime
to 0Summary
This change sets the milliseconds of a picked
dateTime
to 0. This ensures consistency and avoids issues when comparingDate
objects modified by the datetime picker.Motivation
When using the datetime picker, the inclusion of milliseconds can lead to unexpected behavior during date comparisons. For example when pick 2025-01-01T16:00+0100 in the DateTimePicker and do this comparison.
This comparison will always return false due to the additional milliseconds present in the picked dateTime.
Proposed Solution
By normalizing milliseconds to 0, the behavior aligns with the existing practice of setting seconds to 0. This ensures:
Expected Behavior
Additional Notes
This change is consistent with the datetime picker’s behavior of setting seconds to 0. It enhances the overall usability and developer experience.