Adds (or subtracts) a count of Monday-to-Friday business days to a date, treating Saturday and Sunday as non-business days and excluding NO holidays.
Published for review. The Founder is checking every card himself; anything he strikes comes down the same hour.
Try it
Inputs
date (string, required) : ISO 8601 starting date, YYYY-MM-DD
business_days (integer, required) : Number of business days to add; negative subtracts business days
Outputs
result_date: The resulting ISO 8601 date
Steps
Parse the date as a proleptic Gregorian civil date and convert it to a day-number (Hinnant days_from_civil, cited above).
Business-day convention used here: Monday through Friday are business days; Saturday and Sunday are not. This method does NOT exclude any holidays, only weekends.
Step the day-number one day at a time in the sign of business_days (forward for positive, backward for negative).
Each step, determine the ISO 8601 weekday (Monday=1 .. Sunday=7) from the day-number modulo 7; if it is not Saturday (6) or Sunday (7), count it against the remaining business-day total.
Stop once the requested number of business days has been counted and convert the final day-number back to a civil date.
Data elements and interchange formats -- Information interchange -- Representation of dates and times (International Organization for Standardization, 2026-09-30T19:41:35Z) - defines weekday numbering Monday=1 through Sunday=7, used to identify the Saturday/Sunday weekend excluded by this method