troubleshooting Question

Exclude holidays when counting days in jQuery datepicker range

Avatar of peps03
peps03 asked on
jQueryJavaScriptAJAX
6 Comments2 Solutions2196 ViewsLast Modified:
Hi,

This piece of code reduces the weekends from a range of selected days in jQuery datepicker:

var start = new Date($("#startdate").val().split("/").reverse().join(","));
var end = new Date($("#enddate").val().split("/").reverse().join(","));

var weekend_count = 0;
for (i = start.valueOf(); i <= end.valueOf(); i+= 86400000){
	var temp = new Date(i);
	if (temp.getDay() == 0 || temp.getDay() == 6) {
		weekend_count++;
	}
}				
$("#days").val((end - start) / 86400000 + 1 - weekend_count);        

I would like to alter it so also specific holidays that fall within the selected range are reduced:
var currentYear = (new Date).getFullYear();
var disabledDays = ["1-1-"+currentYear,"25-12-"+currentYear,"26-12-"+currentYear];

How should i alter the code?
Thanks!
ASKER CERTIFIED SOLUTION
Mrunal

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 2 Answers and 6 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 2 Answers and 6 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros