Excluding weekends and holidays
Hello,
May be the question has already been answered but I am strugling to find the right answer for my situation.
I have a pdf form. The user input a date "from" and a date "to". My script is able to get the difference in days. But how:
- exclude weekends
- create a fuction with all holidays in a year to automatically exclude them during calculation?
Here is my script. Please take into consideration my input field, I am new to adobe script.
// get the end date value
var cEnd = this.getField("To").value;
// get the start date value
var cStart = this.getField("From").value;
event.value = "";
// compute number of days
if(cEnd != "" & cStart != '') {
// convert date strings to objects
var oEnd = util.scand("dd/mmm/yyyy H:MM:SS", cEnd + " 0:00:00");
var oStart =util.scand("dd/mmm/yyyy H:MM:SS", cStart + " 0:00:00");
// convert into days since epoch date
var nEnd = Math.floor(Number(oEnd) / (1000 * 60 * 60 * 24));
var nStart = Math.floor(Number(oStart) / (1000 * 60 * 60 * 24));
// compute difference
event.value = nEnd - nStart;
}
