I need to enable the hours based in this rule: Starting 1 hour from now and allow a range of 8 hours.
E.G, say now it's 13:00. So my picker should allow only hours between 14:00 - 22:00. If the current time its 21:00, it should allow 22:00 - 06:00.
Here's the code of my Date Picker:
const datePicker = () => {
$('.datetimepicker').datetimepicker({
format: 'LT',
locale: 'PT-BR',
icons: {
up: "fa fa-chevron-up",
down: "fa fa-chevron-down",
},
stepping: 15,
});
};
I created some helper functions to get the edges.
const hourStart = () => {
const start = new Date();
start.setHours(start.getHours() + 1);
return start;
}
const hourFinish = () => {
const finish = new Date()
finish.setHours(hourStart().getHours() + 8);
return finish;
}
I couldn't find anything in documentation which allows set the enabled time interval, only the exact oposite Disable Time Intervals.
Maybe using the Enabled Hours and some sort of Circular List?
There's any other way to achieve the expected behavior using this plugin?