Adding n Number of business days to the specified date :


The following code will generate add n business days to a date (d).

var londonTime = format.format({
                            value: date,
                            type: format.Type.DATE,
                            timezone: format.Timezone.EUROPE_LONDON
                        });
                       
 londonTime = new Date(londonTime);
 var newDate = addBusinessDays(londonTime, 3);
         


function addBusinessDays(d,n) {
            d = new Date(d.getTime());
            var day = d.getDay();
            d.setDate(d.getDate() + n + (day === 6 ? 2 : +!day) + (Math.floor((n - 1 + (day % 6 || 1)) / 5) * 2));
            return d;
        }

Leave a comment

Your email address will not be published. Required fields are marked *