34 ext::shared_ptr<DayCounter::Impl>
38 return ext::shared_ptr<DayCounter::Impl>(
new US_Impl);
41 return ext::shared_ptr<DayCounter::Impl>(
new EU_Impl);
43 return ext::shared_ptr<DayCounter::Impl>(
new IT_Impl);
46 return ext::shared_ptr<DayCounter::Impl>(
new ISMA_Impl);
49 return ext::shared_ptr<DayCounter::Impl>(
new ISDA_Impl(terminationDate));
51 return ext::shared_ptr<DayCounter::Impl>(
new NASD_Impl);
53 QL_FAIL(
"unknown 30/360 convention");
58 const Date& d2)
const {
63 if (dd1 == 31) { dd1 = 30; }
64 if (dd2 == 31 && dd1 >= 30) { dd2 = 30; }
66 if (isLastOfFebruary(dd2, mm2, yy2) && isLastOfFebruary(dd1, mm1, yy1)) { dd2 = 30; }
67 if (isLastOfFebruary(dd1, mm1, yy1)) { dd1 = 30; }
69 return 360*(yy2-yy1) + 30*(mm2-mm1) + (dd2-dd1);
73 const Date& d2)
const {
78 if (dd1 == 31) { dd1 = 30; }
79 if (dd2 == 31 && dd1 == 30) { dd2 = 30; }
81 return 360*(yy2-yy1) + 30*(mm2-mm1) + (dd2-dd1);
85 const Date& d2)
const {
90 if (dd1 == 31) { dd1 = 30; }
91 if (dd2 == 31) { dd2 = 30; }
93 return 360*(yy2-yy1) + 30*(mm2-mm1) + (dd2-dd1);
97 const Date& d2)
const {
102 if (dd1 == 31) { dd1 = 30; }
103 if (dd2 == 31) { dd2 = 30; }
105 if (mm1 == 2 && dd1 > 27) { dd1 = 30; }
106 if (mm2 == 2 && dd2 > 27) { dd2 = 30; }
108 return 360*(yy2-yy1) + 30*(mm2-mm1) + (dd2-dd1);
112 const Date& d2)
const {
117 if (dd1 == 31) { dd1 = 30; }
118 if (dd2 == 31) { dd2 = 30; }
120 if (isLastOfFebruary(dd1, mm1, yy1)) { dd1 = 30; }
122 if (d2 != terminationDate_ && isLastOfFebruary(dd2, mm2, yy2)) { dd2 = 30; }
124 return 360*(yy2-yy1) + 30*(mm2-mm1) + (dd2-dd1);
128 const Date& d2)
const {
133 if (dd1 == 31) { dd1 = 30; }
134 if (dd2 == 31 && dd1 >= 30) { dd2 = 30; }
135 if (dd2 == 31 && dd1 < 30) { dd2 = 1; mm2++; }
137 return 360*(yy2-yy1) + 30*(mm2-mm1) + (dd2-dd1);
std::int_fast32_t serial_type
serial number type
static bool isLeap(Year y)
whether the given year is a leap one
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
static ext::shared_ptr< DayCounter::Impl > implementation(Convention c, const Date &terminationDate)
#define QL_FAIL(message)
throw an error (possibly with file and line information)
QL_INTEGER Integer
integer number