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

New feature to disable specific dates

Open sandeepcisin241 opened this issue 13 years ago • 6 comments

Should provide a feature of disabling specific dates like a public holidays, etc

sandeepcisin241 avatar Mar 11 '13 13:03 sandeepcisin241

Planned on asking the same thing.

http://stackoverflow.com/questions/2029626/jquery-datepicker-disable-weekends-holidays-and-the-next-three-working-days

This example is handled through the beforeShowDay event provided by the jquery ui datepicker plugin. This seems to be a simple enough solution that gives full control over the dates. Would it be possible to add a similar event that can be called before adding the active/disabled classes to the dates? We could pass a function name to the beforeShowDay that would get the currently selected date object and it would be up to us to return if it should be disabled or not.

There would need to be a similar event for each of the selectable parts (year, month, day, hour, min). Could just have a general beforeShowPart event that passes the part identifier and a date/time being checked for display.

The developer of the jquery timepicker that expands on the datepicker referenced above brought up the problem in a recent blog post and how it applies to selecting times.
http://trentrichardson.com/2013/02/03/jquery-timepicker-1-2-works-with-jqueryui-1-10/

One quick solution would be to adjust the changeMin, changeHour, changeDay, changeMonth, changeYear to beforeChange and afterChange events. This could simply pass the part (0-6 for min-decade) and the selected date. From this point we could use some js to manually add the disable class on the elements needed. I tried doing this with the existing change events referenced above but these fire before the html is built so any css added would just be replaced by the newly filled html. This would give people who need it the ability to get in and disable elements and i'm sure help with other use cases.

agn507 avatar Mar 12 '13 22:03 agn507

To expand on this with a use case. Our app is handling restaurant hours and needs to handle menu item availability based on a date time selection. Because restaurants can have different hours and dates disabled on different weeks the curent solution to provide only days of week doesn't really help. Same could be said for any type of scheduling app.

We also need full control over the hours/minute selection where we may have multiple blocks of available times. Say from 12am-3am (rollover from hours open on the previous day) 9am-2pm and 3pm-12m. Middle gap isn't likely for a restaurant but could see that for a scheduling system.

It would be help to add some extra attributes for targeting these elements for when attempting to disable assuming the solution in the above comment could be added.

I've tried several datetime pickers but for my use case nothing really fit well. Your solution with breaking the part selection into new screens works perfectly. It provides a logical progression down through the more granular information providing minimal information. The simple buttons works great on mobile/touch devices as well. Just wanted to say thanks for all the work!

agn507 avatar Mar 12 '13 22:03 agn507

Very good suggestion and very open implementation. I like it ! I'll study it

smalot avatar Mar 18 '13 23:03 smalot

any news about this feature? is there a way to disable times on specific days so there are no double bookings

sam2332 avatar Jul 10 '14 20:07 sam2332

Any news on this?

colin-ch avatar Jun 03 '15 10:06 colin-ch

Has a feature for disabling specific dates like a public holidays, etc. been implemented yet?

crabeler avatar Aug 22 '16 23:08 crabeler