26 ext::shared_ptr<DayCounter::Impl>
30 return ext::shared_ptr<DayCounter::Impl>(
new Impl);
32 return ext::shared_ptr<DayCounter::Impl>(
new CA_Impl);
34 return ext::shared_ptr<DayCounter::Impl>(
new NL_Impl);
36 QL_FAIL(
"unknown Actual/365 (Fixed) convention");
42 const Date& refPeriodStart,
43 const Date& refPeriodEnd)
const {
55 "invalid reference period for Act/365 Canadian; "
56 "must be longer than a month");
59 if (dcs <
Integer(365/frequency))
62 return 1./frequency - (dcc-dcs)/365.0;
67 const Date& d2)
const {
69 static const Integer MonthOffset[] = {
70 0, 31, 59, 90, 120, 151,
71 181, 212, 243, 273, 304, 334
75 + MonthOffset[d1.
month()-1] + (d1.
year() * 365);
77 + MonthOffset[d2.
month()-1] + (d2.
year() * 365);
93 const Date& d4)
const {
Actual/365 (Fixed) day counter.
Time yearFraction(const Date &d1, const Date &d2, const Date &refPeriodStart, const Date &refPeriodEnd) const override
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Time yearFraction(const Date &d1, const Date &d2, const Date &refPeriodStart, const Date &refPeriodEnd) const override
static ext::shared_ptr< DayCounter::Impl > implementation(Convention)
std::int_fast32_t serial_type
serial number type
Date::serial_type dayCount(const Date &, const Date &) const
Returns the number of days between two dates.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Real Time
continuous quantity with 1-year units
QL_INTEGER Integer
integer number
Real months(const Period &p)
Time daysBetween(const Date &d1, const Date &d2)