Skip to content

Commit

Permalink
[@mantine/dates] DateTimePicker: Set milliseconds to 0 on the result …
Browse files Browse the repository at this point in the history
…date object (#7328)

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.
  • Loading branch information
clarknova authored Jan 7, 2025
1 parent 12e8a52 commit 1f8e582
Showing 1 changed file with 1 addition and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ export const DateTimePicker = factory<DateTimePickerFactory>((_props, ref) => {
timeDate.setHours(hours);
timeDate.setMinutes(minutes);
timeDate.setSeconds(seconds || 0);
timeDate.setMilliseconds(0);
setValue(assignTime(timeDate, _value || shiftTimezone('add', new Date(), ctx.getTimezone())));
}
};
Expand Down

0 comments on commit 1f8e582

Please sign in to comment.