Skip to content

Commit 5517e0a

Browse files
Adjust time calculation to respect daily limits
Cap new time calculation at the last valid interval of the day.
1 parent df2c0c0 commit 5517e0a

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

src/index.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -992,12 +992,14 @@ export class DatePicker extends Component<DatePickerProps, DatePickerState> {
992992
const baseDate = getStartOfDay(currentTime);
993993
const currentMinutes = getHours(currentTime) * 60 + getMinutes(currentTime);
994994

995+
const maxMinutes = 23 * 60 + 60 - timeIntervals; // Cap at last valid interval of the day
995996
let newTime: Date;
996997
if (eventKey === KeyType.ArrowUp) {
997998
const newMinutes = Math.max(0, currentMinutes - timeIntervals);
998999
newTime = addMinutes(baseDate, newMinutes);
9991000
} else {
1000-
newTime = addMinutes(baseDate, currentMinutes + timeIntervals);
1001+
const newMinutes = Math.min(maxMinutes, currentMinutes + timeIntervals);
1002+
newTime = addMinutes(baseDate, newMinutes);
10011003
}
10021004

10031005
const formattedTime = formatDate(

0 commit comments

Comments
 (0)