Quick Links: |
Provide a parameterized day-count convention implementation. More...
Namespaces | |
namespace | bbldc |
bbldc::DateRangeDayCount
adapter bbldc::TerminatedDateRangeDayCountAdapter
, of the bbldc::DateRangeDayCount
protocol that allows for special handling of a termination date (e.g., maturity date). The template argument can be any type supporting the following two class methods. int daysDiff(const bdlt::Date& beginDate, const bdlt::Date& endDate, const bdlt::Date& terminationDate); double yearsDiff(const bdlt::Date& beginDate, const bdlt::Date& endDate, const bdlt::Date& terminationDate);
bbldc::TerminatedDateRangeDayCountAdapter
provides convenient support for run-time polymorphic choice of day-count conventions (via conventional use of a base-class pointer or reference) without having to implement each derived type explicitly. In this sense, bbldc::TerminatedDateRangeDayCountAdapter
adapts the various concrete "terminated" day-count convention classes (e.g., bbldc::TerminatedIsda30360Eom
) to a run-time binding mechanism. bbldc::DateRangeDayCount
protocol requires two methods, firstDate
and lastDate
, that define a date range for which calculations are valid, to reflect the valid range of, say, a calendar required for the computations. For "terminated" day-count implementations, the valid date range is identical to the range of bdlt::Date
. bbldc::TerminatedDateRangeDayCountAdapter
to adapt the bbldc::TerminatedIsda30360Eom
day-count convention to the bbldc::DateRangeDayCount
protocol, and then the use of the day-count methods. bbldc::TerminatedIsda30360Eom
day-count convention and obtain a reference to the bbldc::DateRangeDayCount
: const bbldc::TerminatedDateRangeDayCountAdapter< bbldc::TerminatedIsda30360Eom> myDcc(bdlt::Date(2004, 2, 29)); const bbldc::DateRangeDayCount& dcc = myDcc;
bdlt::Date
variables, d1
and d2
, with which to use the day-count convention methods: const bdlt::Date d1(2003, 10, 18); const bdlt::Date d2(2003, 12, 31);
const int daysDiff = dcc.daysDiff(d1, d2); assert(72 == daysDiff);
const double yearsDiff = dcc.yearsDiff(d1, d2); // Need fuzzy comparison since 'yearsDiff' is a 'double'. assert(0.1999 < yearsDiff && 0.2001 > yearsDiff);