-
-
Save mazipan/b973e385c2e8e679801b2fb44c19a745 to your computer and use it in GitHub Desktop.
JavaScript : Add Business days to a date
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// https://github.com/lsmith/addBusinessDays/blob/master/addBusinessDays.js | |
// var d = new Date(); | |
// addBusinessDays(d, numberOfDays); | |
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; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment