Counting Rules
How JDay counts business days — start date exclusion, end date inclusion, and edge cases.
JDay uses deterministic counting rules across all computation endpoints.
Business Day Definition
A business day is any date that is:
- Not a weekend for the target country on that date
- Not a national or regional holiday that is a non-working day on that date
Half-days are out of scope for v1.
add-business-days
Core Rule
- The start date is never counted.
- Computation moves one calendar day at a time in the sign direction of
days. - A traversed date counts toward the target only if it is a business day.
- Weekends and holidays are skipped but tracked in the response metadata.
days Parameter
| Value | Behavior |
|---|---|
days > 0 | Move forward |
days < 0 | Move backward |
days = 0 | Return the original input date unchanged |
When days = 0:
holidays_skipped: []weekends_skipped: 0calendar_days_elapsed: 0
Signed Fields
business_days_addedechoes the signed input.calendar_days_elapsedis signed: positive forward, negative backward, zero fordays = 0.weekends_skippedis always a non-negative absolute count.holidays_skippedis always sorted chronologically (earlier to later), regardless of traversal direction.
Overlap Rule
When a holiday falls on a weekend:
- The weekend date increments
weekends_skipped holidays_skippedincludes only holiday records whose effective date is a traversed non-weekend date- If multiple holiday records share the same traversed non-weekend date, all appear in
holidays_skipped
count-business-days
Core Rule
- The start date is excluded.
- The end date is included.
- If
startequalsend, all counts are zero andholidaysis empty. - If
start > end,business_daysis negative.
Absolute vs Signed Fields
business_daysmay be negative (for reverse-order queries).total_calendar_days,weekends, andholidays_on_weekdaysare always non-negative absolute counts.holidaysis always sorted chronologically from earlier to later, then byname.
Holiday Inclusion Rule
holidays_on_weekdayscounts distinct traversed dates that have at least one holiday record and are not weekend dates.holidayscontains all holiday records on those weekday-holiday dates.- Holidays falling on weekends are excluded from both
holidays_on_weekdaysandholidaysbecause those dates are classified underweekends.
Reverse-Order Example
start=2026-01-10&end=2026-01-07 traverses dates 2026-01-09, 2026-01-08, and 2026-01-07. It excludes 2026-01-10 (start) and includes 2026-01-07 (end).