soyuka/dpicker

problem with min and steps

Closed this issue · 0 comments

Hi.

First of all: THANKS!

I think there is a little bug:

Let's say it's 14:58right now and I start the picker with picker.min = moment()
Than the select field for the hour is 14and the minute select is empty, because there is no step left for the hour 14.
This happens just for sameDay

I think you need something like this (modified for individual steps of course, mine is for step = 15):

function roundValue(val) {
    var m = (parseInt((val.minutes() + 7.5)/15) * 15) % 60;
    var h = val.minutes() > 52 ? (val.hours() === 23 ? 0 : val.add(1, 'hour').hours()) : val.hours();
    return val.hours(h).minutes(m);
}

Another problem:
When it's 15:05 and that's also the min. Than the minutes-select has the options 15, 30and 45. Changing the hour to 16 doesn't enable the option 00.