bootstrap-timepicker icon indicating copy to clipboard operation
bootstrap-timepicker copied to clipboard

Minute Decrements Inconsistent with Increments

Open drbenschmidt opened this issue 12 years ago • 2 comments

When the user increments the minute value, it will jump to the nearest multiple of the minuteStep, but not for decrements. I'm not sure this is correct behavior, but if it isn't, here's a suggested fix (although it's not as elegant as the increment code):

    var newVal;
    if((this.minute - this.minuteStep) % this.minuteStep != 0) {
        if(this.minute - this.minuteStep < 0) {
            newVal = 0;
        } else {
            newVal = this.minute - ((this.minute - this.minuteStep) % this.minuteStep);
        }
    } else {
         newVal = this.minute - this.minuteStep;
    }

drbenschmidt avatar Jan 09 '14 15:01 drbenschmidt

Is there a fix for this issue? Here's my scenario:

  1. minute value = 12 with minuteStep = 5
  2. Clicked on arrow down. This will give me 07, then 02 after clicking it again.
  3. Clicked on arrow up. This will give me 10, then after clicking it again will give me 15.

Why did it changed to the nearest multiple after clicking arrow up instead of

current value + minuteStep

mmrenomeron avatar Feb 28 '14 12:02 mmrenomeron

When the user increments the minute value, it will jump to the nearest multiple of the minuteStep, but not for decrements. I'm not sure this is correct behavior, but if it isn't, here's a suggested fix (although it's not as elegant as the increment code):

    var newVal;
    if((this.minute - this.minuteStep) % this.minuteStep != 0) {
        if(this.minute - this.minuteStep < 0) {
            newVal = 0;
        } else {
            newVal = this.minute - ((this.minute - this.minuteStep) % this.minuteStep);
        }
    } else {
         newVal = this.minute - this.minuteStep;
    }

I'm using this timepicker for a Yii2 project where do i do the suggested changes..?

cyberatom3000 avatar Apr 12 '21 11:04 cyberatom3000