[Feature request] Exclude given times from the dropdown #86

Open
devhitech opened this Issue Oct 27, 2016 · 1 comment

Projects

None yet

1 participant

@devhitech

The timepicker works great with the min/maxTime/Hour/Minute to set the limits of the shown values.

However there's no option to add a gap/exclusion inside the set interval.

Example of the option (highlighted) I'm looking for:

$('#mytimepicker');.timepicker({
    timeFormat: 'HH:mm',
    interval: 60,
    minHour: 9,
    maxHour: 18,
    **exclude: 12, 15**
});

This would show a dropdown with all the hours between 9 and 18, except 12 and 15.

@devhitech

I looked quickly over the JS code, and the following small change should do the trick (only works with 1 value in the exclude - for my particular use case it's fine for now - I called the option exHour, exHour: 12).

Inside _isValidTime: function(i, time) { having the exHour option added and the corresponding vars:

                if (i.options.exHour !== null) {
                    ex = normalize(i.options.exHour, null);
                }
                if (ex !== null) {
                    if (Date.parse(time) === Date.parse(ex)) {
                        return false;
                    }
                }

Would be nice to have this feature in the main release though.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment