Subtract business days from original if valid.

Synopsis

Declared in <bdlt_calendarutil.h>

static
int
subtractBusinessDaysIfValid(
    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 before the specified original date according to the specified calendar. The resulting date is chronologically before the original date for positive values of numBusinessDays, the chronologically latest business day that is on or before the original date for 0 == numBusinessDays, and chronologically after the original date for negative 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 subtractBusinessDaysIfValid(res, orig, cal, numBusinessDays) is identical to the result of addBusinessDaysIfValid(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 subtract (may be negative)

Created with MrDocs