I have two text fields. In the first textfield I have added a calendar using jQueryUI Datepicker. When the user selects the date from the datepicker, it should automatically
When dealing with holidays, there's really only one option: one day at a time. You should iterate, one day at a time, and add/substract as needed if a day "counts". In pseudo code:
date add(date startDate, int daysToAdd) {
int i:=0
endDate:=startDate
while (i
isWeekend()
is trivial to implement; isHoliday()
, on the other hand, is a very tough nut to crack. The easiest way to deal with it is to have a table of known holidays and check if the date passed as parameter coincides with any of those. In my opinion, it's better to have a rule-based method that can compute whether a given date is a holiday or not.
Disclaimer: I copied and pasted this from a previous answer of mine to the same question. See How to ignore weekends and holidays in boost date time?