double PeriodDayCountUtil::yearsDiff(
                                 const bdlt::Date&              beginDate,
                                 const bdlt::Date&              endDate,
                                 const bsl::vector<bdlt::Date>& periodDate,
                                 double                         periodYearDiff,
                                 DayCountConvention::Enum       convention)
{
    BSLS_ASSERT(periodDate.size() >= 2);
    BSLS_ASSERT(periodDate.front() <= beginDate);
    BSLS_ASSERT(                      beginDate <= periodDate.back());
    BSLS_ASSERT(periodDate.front() <= endDate);
    BSLS_ASSERT(                      endDate   <= periodDate.back());

    BSLS_ASSERT_SAFE(isSortedAndUnique(periodDate.begin(), periodDate.end()));

    double numYears;

    switch (convention) {
      case DayCountConvention::e_PERIOD_ICMA_ACTUAL_ACTUAL: {
        numYears = bbldc::PeriodIcmaActualActual::yearsDiff(beginDate,
                                                            endDate,
                                                            periodDate,
                                                            periodYearDiff);
      } break;
      default: {
        BSLS_ASSERT_OPT(0 && "Unrecognized convention");
        numYears = 0.0;
      } break;
    }

    return numYears;
}
Esempio n. 2
0
 inline
 const bsl::shared_ptr<ball::Record>& my_RecordBuffer::front() const
 {
     bslmt::LockGuard<bslmt::RecursiveMutex> guard(&d_mutex);
     return d_buffer.front();
 }