Skip to content

Commit

Permalink
fix(timepicker): update incrementHours logic
Browse files Browse the repository at this point in the history
  • Loading branch information
daniloff200 committed Jan 15, 2020
1 parent 3c90957 commit ac8f109
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 5 deletions.
3 changes: 2 additions & 1 deletion src/timepicker/timepicker-controls.util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export function timepickerControls(
value: Date,
state: TimepickerComponentState
): TimepickerControls {
const hoursPerDay = 24;
const hoursPerDayHalf = 12;
const { min, max, hourStep, minuteStep, secondsStep, showSeconds } = state;
const res: TimepickerControls = {
Expand All @@ -140,7 +141,7 @@ export function timepickerControls(
// compare dates
if (max) {
const _newHour = changeTime(value, { hour: hourStep });
res.canIncrementHours = max > _newHour;
res.canIncrementHours = max > _newHour && (value.getHours() + hourStep) < hoursPerDay;

if (!res.canIncrementHours) {
const _newMinutes = changeTime(value, { minute: minuteStep });
Expand Down
4 changes: 0 additions & 4 deletions src/timepicker/timepicker.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,6 @@ export function changeTime(value: Date, diff: Time): Date {
hour = (hour + toNumber(diff.hour)) % hoursPerDay;
if (hour < 0) {
hour += hoursPerDay;
} else if (hour === 0) {
hour = 23;
minutes = 59;
seconds = 59;
}
}

Expand Down

0 comments on commit ac8f109

Please sign in to comment.