BloombergLP::bdlt::DateUtil::addYearsEom

Return original advanced by numYears with end-of-month rules.

Synopsis

Declared in <bdlt_dateutil.h>

static
Date
addYearsEom(
    Date const& original,
    int numYears);

Description

Return the date that is the specified numYears from the specified original date, adjusted as necessary according to the following (end-of-month) rules: (1) if original is the last day of a month, adjust the result to be the last day of the month, and (2) if the day of the month in original does not exist in the month of the result (e.g., February 29, 2001), move the resulting date to the last day of the month. The behavior is undefined unless the operation results in a valid Date value. Note that numYears may be negative.

Return Value

resulting date

Parameters

NameDescription
originalstarting date
numYearsyears to add (may be negative)