Add or subtract business days from original if valid.

Synopsis

Declared in <bdlt_calendarutil.h>

static
int
addBusinessDaysIfValid(
    bdlt::Date* result,
    bdlt::Date const& original,
    bdlt::Calendar const& calendar,
    int numBusinessDays);

Description

Load, into the specified result, the date that is the specified numBusinessDays chronologically after the specified original date according to the specified calendar. The resulting date is chronologically before the original date for negative values of numBusinessDays, the chronologically earliest business day that is on or after the original date for 0 == numBusinessDays, and chronologically after the original date for positive values of numBusinessDays. Return 0 on success, and a non‐zero value, without modifying *result, if either the original date or the resulting date is not within the valid range of calendar. Note that if 0 != numBusinessDays, then the result of addBusinessDaysIfValid(res, orig, cal, numBusinessDays) is identical to the result of subtractBusinessDaysIfValid(res, orig, cal, ‐numBusinessDays).

Return Value

0 on success, non‐zero on failure

Parameters

Name

Description

result

destination for the resulting date

original

starting date

calendar

calendar used for business‐day determination

numBusinessDays

business days to add (may be negative)

Created with MrDocs