Created
March 23, 2009 17:18
-
-
Save lsmith/83668 to your computer and use it in GitHub Desktop.
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
// Adds n weekdays to Date d. Weekdays are Mon-Fri. Holidays are not accounted for. | |
// Adding 0 days to a weekend day will return Monday's Date. | |
function addWeekdays(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