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

Fix #2301: Calendar stepMinute in proper increments #2451

Merged
merged 1 commit into from
Dec 10, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 18 additions & 2 deletions src/components/calendar/Calendar.js
Original file line number Diff line number Diff line change
Expand Up @@ -879,10 +879,26 @@ export class Calendar extends Component {
event.preventDefault();
}

doStepMinute(currentMinute, step) {
if (this.props.stepMinute <= 1) {
return currentMinute;
}
if (!step) {
step = this.props.stepMinute;
if (currentMinute % step === 0) {
return currentMinute;
}
}

var newMinute = currentMinute + step;
newMinute = Math.floor(newMinute / step) * step;
return newMinute;
}

incrementMinute(event) {
const currentTime = this.getCurrentDateTime();
const currentMinute = currentTime.getMinutes();
let newMinute = currentMinute + this.props.stepMinute;
let newMinute = this.doStepMinute(currentMinute, this.props.stepMinute);
newMinute = (newMinute > 59) ? (newMinute - 60) : newMinute;

if (this.validateMinute(newMinute, currentTime)) {
Expand Down Expand Up @@ -910,7 +926,7 @@ export class Calendar extends Component {
decrementMinute(event) {
const currentTime = this.getCurrentDateTime();
const currentMinute = currentTime.getMinutes();
let newMinute = currentMinute - this.props.stepMinute;
let newMinute = this.doStepMinute(currentMinute, -this.props.stepMinute);
newMinute = (newMinute < 0) ? (newMinute + 60) : newMinute;

if (this.validateMinute(newMinute, currentTime)) {
Expand Down