/src/quantlib/ql/time/calendars/romania.cpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2010 StatPro Italia srl |
5 | | Copyright (C) 2015 Riccardo Barone |
6 | | Copyright (C) 2018 Matthias Lungwitz |
7 | | |
8 | | This file is part of QuantLib, a free-software/open-source library |
9 | | for financial quantitative analysts and developers - http://quantlib.org/ |
10 | | |
11 | | QuantLib is free software: you can redistribute it and/or modify it |
12 | | under the terms of the QuantLib license. You should have received a |
13 | | copy of the license along with this program; if not, please email |
14 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
15 | | <http://quantlib.org/license.shtml>. |
16 | | |
17 | | This program is distributed in the hope that it will be useful, but WITHOUT |
18 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
19 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
20 | | */ |
21 | | |
22 | | #include <ql/time/calendars/romania.hpp> |
23 | | #include <ql/errors.hpp> |
24 | | |
25 | | namespace QuantLib { |
26 | | |
27 | 0 | Romania::Romania(Market market) { |
28 | | // all calendar instances share the same implementation instance |
29 | 0 | static ext::shared_ptr<Calendar::Impl> publicImpl = |
30 | 0 | ext::make_shared<Romania::PublicImpl>(); |
31 | 0 | static ext::shared_ptr<Calendar::Impl> bvbImpl = |
32 | 0 | ext::make_shared<Romania::BVBImpl>(); |
33 | 0 | switch (market) { |
34 | 0 | case Public: |
35 | 0 | impl_ = publicImpl; |
36 | 0 | break; |
37 | 0 | case BVB: |
38 | 0 | impl_ = bvbImpl; |
39 | 0 | break; |
40 | 0 | default: |
41 | 0 | QL_FAIL("unknown market"); |
42 | 0 | } |
43 | 0 | } |
44 | | |
45 | 0 | bool Romania::PublicImpl::isBusinessDay(const Date& date) const { |
46 | 0 | Weekday w = date.weekday(); |
47 | 0 | Day d = date.dayOfMonth(), dd = date.dayOfYear(); |
48 | 0 | Month m = date.month(); |
49 | 0 | Year y = date.year(); |
50 | 0 | Day em = easterMonday(y); |
51 | 0 | if (isWeekend(w) |
52 | | // New Year's Day |
53 | 0 | || (d == 1 && m == January) |
54 | | // Day after New Year's Day |
55 | 0 | || (d == 2 && m == January) |
56 | | // Unification Day |
57 | 0 | || (d == 24 && m == January) |
58 | | // Orthodox Easter Monday |
59 | 0 | || (dd == em) |
60 | | // Labour Day |
61 | 0 | || (d == 1 && m == May) |
62 | | // Pentecost |
63 | 0 | || (dd == em+49) |
64 | | // Children's Day (since 2017) |
65 | 0 | || (d == 1 && m == June && y >= 2017) |
66 | | // St Marys Day |
67 | 0 | || (d == 15 && m == August) |
68 | | // Feast of St Andrew |
69 | 0 | || (d == 30 && m == November) |
70 | | // National Day |
71 | 0 | || (d == 1 && m == December) |
72 | | // Christmas |
73 | 0 | || (d == 25 && m == December) |
74 | | // 2nd Day of Chritsmas |
75 | 0 | || (d == 26 && m == December)) |
76 | 0 | return false; // NOLINT(readability-simplify-boolean-expr) |
77 | 0 | return true; |
78 | 0 | } |
79 | | |
80 | 0 | bool Romania::BVBImpl::isBusinessDay(const Date& date) const { |
81 | 0 | if (!PublicImpl::isBusinessDay(date)) |
82 | 0 | return false; |
83 | 0 | Day d = date.dayOfMonth(); |
84 | 0 | Month m = date.month(); |
85 | 0 | Year y = date.year(); |
86 | 0 | if (// one-off closing days |
87 | 0 | (d == 24 && m == December && y == 2014) || |
88 | 0 | (d == 31 && m == December && y == 2014) |
89 | 0 | ) |
90 | 0 | return false; // NOLINT(readability-simplify-boolean-expr) |
91 | 0 | return true; |
92 | 0 | } |
93 | | |
94 | | } |
95 | | |