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

Normalize milliseconds in picked dateTime in DateTimePicker to 0 #7328

Merged
merged 1 commit into from
Jan 7, 2025

Conversation

clarknova
Copy link
Contributor

Normalize milliseconds in picked dateTime to 0

Summary

This change sets the milliseconds of a picked dateTime to 0. This ensures consistency and avoids issues when comparing Date 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.

new Date('2025-01-01T16:00+0100') >= <DatePickedWithDateTimePicker>

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:

  • More intuitive and predictable behavior.
  • Easier comparisons between Date objects.

Expected Behavior

  • The milliseconds of all picked dateTime values will now default to 0.
  • Comparisons like the example above will behave as expected.

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.

This sets the milliseconds to 0.
Otherwise comparisons with Dates changed by the datetimepicker become very annoying.
For Example:

```new Date('2025-01-01T16:00+0100') >= <DatePickedWithDateTimePicker>``` is always false because of the milliseconds added.
@clarknova clarknova changed the title Update DateTimePicker.tsx Normalize milliseconds in picked dateTime in DateTimePicker to 0 Jan 4, 2025
@rtivital rtivital merged commit 1f8e582 into mantinedev:master Jan 7, 2025
1 check passed
@rtivital
Copy link
Member

rtivital commented Jan 7, 2025

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants