Shift original with special‐day handling if valid.

Synopsis

Declared in <bdlt_calendarutil.h>

static
int
shiftIfValid(
    bdlt::Date* result,
    bdlt::Date const& original,
    bdlt::Calendar const& calendar,
    ShiftConvention convention,
    bdlt::DayOfWeek::Enum specialDay,
    bool extendSpecialDay,
    ShiftConvention specialConvention);

Description

Load, into the specified result, the date of the business day that is derived from the specified original date based on the specified calendar according to the specified date‐shifting convention, except when the original is either the specified specialDay of the week, or ‐ if the specified extendSpecialDay is true ‐ one of the (possibly empty) set of contiguous non‐business days immediately preceding a specialDay according to the calendar, in which case the result is determined using the specified specialConvention. Return 0 on success, and a non‐zero value, without modifying *result, if a valid business date cannot be found according to the above algorithm within the valid range of calendar. Note that this method is useful for computing, for example, Korean bond coupon payment dates.

Return Value

0 on success, non‐zero on failure

Parameters

Name

Description

result

destination for the shifted date

original

starting date

calendar

calendar used for business‐day determination

convention

date‐shifting convention to apply

specialDay

day of week that triggers special handling

extendSpecialDay

whether non‐business days preceding specialDay also use specialConvention

specialConvention

convention used for special‐day cases

Created with MrDocs