34 const Date& from,
const Date& to,
35 bool includeFirst,
bool includeLast) {
37 for (Date
d = includeFirst ? from : from + 1;
d < to; ++
d) {
48#ifdef QL_HIGH_RESOLUTION_DATE
49 const Date _d(
d.dayOfMonth(),
d.month(),
d.year());
55 impl_->removedHolidays.erase(_d);
58 if (
impl_->isBusinessDay(_d))
59 impl_->addedHolidays.insert(_d);
65#ifdef QL_HIGH_RESOLUTION_DATE
66 const Date _d(
d.dayOfMonth(),
d.month(),
d.year());
72 impl_->addedHolidays.erase(_d);
75 if (!
impl_->isBusinessDay(_d))
76 impl_->removedHolidays.insert(_d);
80 impl_->addedHolidays.clear();
81 impl_->removedHolidays.clear();
98 if (d1.
month() !=
d.month()) {
102 if (
d.dayOfMonth() <= 15 && d1.
dayOfMonth() > 15) {
125 QL_FAIL(
"unknown business-day convention");
133 bool endOfMonth)
const {
137 }
else if (unit ==
Days) {
155 }
else if (unit ==
Weeks) {
178 bool endOfMonth)
const {
185 bool includeLast)
const {
186 return (from < to) ? daysBetweenImpl(*
this, from, to, includeFirst, includeLast) :
187 (from > to) ? -daysBetweenImpl(*
this, to, from, includeLast, includeFirst) :
200 static const Day EasterMonday[] = {
201 98, 90, 103, 95, 114, 106, 91, 111, 102,
202 87, 107, 99, 83, 103, 95, 115, 99, 91, 111,
203 96, 87, 107, 92, 112, 103, 95, 108, 100, 91,
204 111, 96, 88, 107, 92, 112, 104, 88, 108, 100,
205 85, 104, 96, 116, 101, 92, 112, 97, 89, 108,
206 100, 85, 105, 96, 109, 101, 93, 112, 97, 89,
207 109, 93, 113, 105, 90, 109, 101, 86, 106, 97,
208 89, 102, 94, 113, 105, 90, 110, 101, 86, 106,
209 98, 110, 102, 94, 114, 98, 90, 110, 95, 86,
210 106, 91, 111, 102, 94, 107, 99, 90, 103, 95,
211 115, 106, 91, 111, 103, 87, 107, 99, 84, 103,
212 95, 115, 100, 91, 111, 96, 88, 107, 92, 112,
213 104, 95, 108, 100, 92, 111, 96, 88, 108, 92,
214 112, 104, 89, 108, 100, 85, 105, 96, 116, 101,
215 93, 112, 97, 89, 109, 100, 85, 105, 97, 109,
216 101, 93, 113, 97, 89, 109, 94, 113, 105, 90,
217 110, 101, 86, 106, 98, 89, 102, 94, 114, 105,
218 90, 110, 102, 86, 106, 98, 111, 102, 94, 114,
219 99, 90, 110, 95, 87, 106, 91, 111, 103, 94,
220 107, 99, 91, 103, 95, 115, 107, 91, 111, 103,
221 88, 108, 100, 85, 105, 96, 109, 101, 93, 112,
222 97, 89, 109, 93, 113, 105, 90, 109, 101, 86,
223 106, 97, 89, 102, 94, 113, 105, 90, 110, 101,
224 86, 106, 98, 110, 102, 94, 114, 98, 90, 110,
225 95, 86, 106, 91, 111, 102, 94, 107, 99, 90,
226 103, 95, 115, 106, 91, 111, 103, 87, 107, 99,
227 84, 103, 95, 115, 100, 91, 111, 96, 88, 107,
228 92, 112, 104, 95, 108, 100, 92, 111, 96, 88,
229 108, 92, 112, 104, 89, 108, 100, 85, 105, 96,
230 116, 101, 93, 112, 97, 89, 109, 100, 85, 105
232 return EasterMonday[
y-1901];
242 static const Day EasterMonday[] = {
243 105, 118, 110, 102, 121, 106, 126, 118, 102,
244 122, 114, 99, 118, 110, 95, 115, 106, 126, 111,
245 103, 122, 107, 99, 119, 110, 123, 115, 107, 126,
246 111, 103, 123, 107, 99, 119, 104, 123, 115, 100,
247 120, 111, 96, 116, 108, 127, 112, 104, 124, 115,
248 100, 120, 112, 96, 116, 108, 128, 112, 104, 124,
249 109, 100, 120, 105, 125, 116, 101, 121, 113, 104,
250 117, 109, 101, 120, 105, 125, 117, 101, 121, 113,
251 98, 117, 109, 129, 114, 105, 125, 110, 102, 121,
252 106, 98, 118, 109, 122, 114, 106, 118, 110, 102,
253 122, 106, 126, 118, 103, 122, 114, 99, 119, 110,
254 95, 115, 107, 126, 111, 103, 123, 107, 99, 119,
255 111, 123, 115, 107, 127, 111, 103, 123, 108, 99,
256 119, 104, 124, 115, 100, 120, 112, 96, 116, 108,
257 128, 112, 104, 124, 116, 100, 120, 112, 97, 116,
258 108, 128, 113, 104, 124, 109, 101, 120, 105, 125,
259 117, 101, 121, 113, 105, 117, 109, 101, 121, 105,
260 125, 110, 102, 121, 113, 98, 118, 109, 129, 114,
261 106, 125, 110, 102, 122, 106, 98, 118, 110, 122,
262 114, 99, 119, 110, 102, 115, 107, 126, 118, 103,
263 123, 115, 100, 120, 112, 96, 116, 108, 128, 112,
264 104, 124, 109, 100, 120, 105, 125, 116, 108, 121,
265 113, 104, 124, 109, 101, 120, 105, 125, 117, 101,
266 121, 113, 98, 117, 109, 129, 114, 105, 125, 110,
267 102, 121, 113, 98, 118, 109, 129, 114, 106, 125,
268 110, 102, 122, 106, 126, 118, 103, 122, 114, 99,
269 119, 110, 102, 115, 107, 126, 111, 103, 123, 114,
270 99, 119, 111, 130, 115, 107, 127, 111, 103, 123,
271 108, 99, 119, 104, 124, 115, 100, 120, 112, 103,
272 116, 108, 128, 119, 104, 124, 116, 100, 120, 112
274 return EasterMonday[
y-1901];
278 const Date& from,
const Date& to,
bool includeWeekEnds)
const {
281 << from <<
") must be equal to or earlier than 'to' date ("
283 std::vector<Date> result;
284 for (
Date d = from;
d <= to; ++
d) {
292 const Date& from,
const Date& to)
const {
295 << from <<
") must be equal to or earlier than 'to' date ("
297 std::vector<Date> result;
298 for (
Date d = from;
d <= to; ++
d) {
static Day easterMonday(Year)
expressed relative to first day of year
bool isWeekend(Weekday) const override
static Day easterMonday(Year)
expressed relative to first day of year
bool isWeekend(Weekday) const override
bool isWeekend(Weekday w) const
Date::serial_type businessDaysBetween(const Date &from, const Date &to, bool includeFirst=true, bool includeLast=false) const
void removeHoliday(const Date &)
bool isEndOfMonth(const Date &d) const
bool isBusinessDay(const Date &d) const
void addHoliday(const Date &)
Date adjust(const Date &, BusinessDayConvention convention=Following) const
std::vector< Date > holidayList(const Date &from, const Date &to, bool includeWeekEnds=false) const
bool isHoliday(const Date &d) const
Date advance(const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following, bool endOfMonth=false) const
ext::shared_ptr< Impl > impl_
void resetAddedAndRemovedHolidays()
std::vector< Date > businessDayList(const Date &from, const Date &to) const
Date endOfMonth(const Date &d) const
last business day of the month to which the given date belongs
static Date endOfMonth(const Date &d)
last day of the month to which the given date belongs
static bool isEndOfMonth(const Date &d)
whether a date is the last day of its month
std::int_fast32_t serial_type
serial number type
Classes and functions for error handling.
#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)
TimeUnit
Units used to describe time periods.
BusinessDayConvention
Business Day conventions.
@ HalfMonthModifiedFollowing
QL_INTEGER Integer
integer number