1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2004 StatPro Italia srl
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20#include <ql/time/calendars/austria.hpp>
21#include <ql/errors.hpp>
22
23namespace QuantLib {
24
25 Austria::Austria(Austria::Market market) {
26 // all calendar instances on the same market share the same
27 // implementation instance
28 static ext::shared_ptr<Calendar::Impl> settlementImpl(
29 new Austria::SettlementImpl);
30 static ext::shared_ptr<Calendar::Impl> exchangeImpl(
31 new Austria::ExchangeImpl);
32 switch (market) {
33 case Settlement:
34 impl_ = settlementImpl;
35 break;
36 case Exchange:
37 impl_ = exchangeImpl;
38 break;
39 default:
40 QL_FAIL("unknown market");
41 }
42 }
43
44
45 bool Austria::SettlementImpl::isBusinessDay(const Date& date) const {
46 Weekday w = date.weekday();
47 Day d = date.dayOfMonth(), dd = date.dayOfYear();
48 Month m = date.month();
49 Year y = date.year();
50 Day em = easterMonday(y);
51 if (isWeekend(w)
52 // New Year's Day
53 || (d == 1 && m == January)
54 // Epiphany
55 || (d == 6 && m == January)
56 // Easter Monday
57 || (dd == em)
58 // Ascension Thurday
59 || (dd == em+38)
60 // Whit Monday
61 || (dd == em+49)
62 // Corpus Christi
63 || (dd == em+59)
64 // Labour Day
65 || (d == 1 && m == May)
66 // Assumption
67 || (d == 15 && m == August)
68 // National Holiday since 1967
69 || (d == 26 && m == October && y >= 1967)
70 // National Holiday 1919-1934
71 || (d == 12 && m == November && y >= 1919 && y <= 1934)
72 // All Saints' Day
73 || (d == 1 && m == November)
74 // Immaculate Conception
75 || (d == 8 && m == December)
76 // Christmas
77 || (d == 25 && m == December)
78 // St. Stephen
79 || (d == 26 && m == December))
80 return false; // NOLINT(readability-simplify-boolean-expr)
81 return true;
82 }
83
84
85 bool Austria::ExchangeImpl::isBusinessDay(const Date& date) const {
86 Weekday w = date.weekday();
87 Day d = date.dayOfMonth(), dd = date.dayOfYear();
88 Month m = date.month();
89 Year y = date.year();
90 Day em = easterMonday(y);
91 if (isWeekend(w)
92 // New Year's Day
93 || (d == 1 && m == January)
94 // Good Friday
95 || (dd == em-3)
96 // Easter Monday
97 || (dd == em)
98 // Whit Monay
99 || (dd == em+49)
100 // Labour Day
101 || (d == 1 && m == May)
102 // National Holiday since 1967
103 || (d == 26 && m == October && y >= 1967)
104 // National Holiday 1919-1934
105 || (d == 12 && m == November && y >= 1919 && y <= 1934)
106 // Christmas' Eve
107 || (d == 24 && m == December)
108 // Christmas
109 || (d == 25 && m == December)
110 // St. Stephen
111 || (d == 26 && m == December)
112 // Exchange Holiday
113 || (d == 31 && m == December))
114 return false; // NOLINT(readability-simplify-boolean-expr)
115 return true;
116 }
117
118}
119
120

source code of quantlib/ql/time/calendars/austria.cpp