Coverage Report

Created: 2026-03-11 06:44

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/time/calendars/italy.cpp
Line
Count
Source
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
 <https://www.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/italy.hpp>
21
#include <ql/errors.hpp>
22
23
namespace QuantLib {
24
25
0
    Italy::Italy(Italy::Market market) {
26
        // all calendar instances on the same market share the same
27
        // implementation instance
28
0
        static ext::shared_ptr<Calendar::Impl> settlementImpl(
29
0
                                                   new Italy::SettlementImpl);
30
0
        static ext::shared_ptr<Calendar::Impl> exchangeImpl(
31
0
                                                   new Italy::ExchangeImpl);
32
0
        switch (market) {
33
0
          case Settlement:
34
0
            impl_ = settlementImpl;
35
0
            break;
36
0
          case Exchange:
37
0
            impl_ = exchangeImpl;
38
0
            break;
39
0
          default:
40
0
            QL_FAIL("unknown market");
41
0
        }
42
0
    }
43
44
45
0
    bool Italy::SettlementImpl::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
            // Epiphany
55
0
            || (d == 6 && m == January)
56
            // Easter Monday
57
0
            || (dd == em)
58
            // Liberation Day
59
0
            || (d == 25 && m == April)
60
            // Labour Day
61
0
            || (d == 1 && m == May)
62
            // Republic Day
63
0
            || (d == 2 && m == June && y >= 2000)
64
            // Assumption
65
0
            || (d == 15 && m == August)
66
            // All Saints' Day
67
0
            || (d == 1 && m == November)
68
            // Immaculate Conception
69
0
            || (d == 8 && m == December)
70
            // Christmas
71
0
            || (d == 25 && m == December)
72
            // St. Stephen
73
0
            || (d == 26 && m == December)
74
            // December 31st, 1999 only
75
0
            || (d == 31 && m == December && y == 1999))
76
0
            return false; // NOLINT(readability-simplify-boolean-expr)
77
0
        return true;
78
0
    }
79
80
81
0
    bool Italy::ExchangeImpl::isBusinessDay(const Date& date) const {
82
0
        Weekday w = date.weekday();
83
0
        Day d = date.dayOfMonth(), dd = date.dayOfYear();
84
0
        Month m = date.month();
85
0
        Year y = date.year();
86
0
        Day em = easterMonday(y);
87
0
        if (isWeekend(w)
88
            // New Year's Day
89
0
            || (d == 1 && m == January)
90
            // Good Friday
91
0
            || (dd == em-3)
92
            // Easter Monday
93
0
            || (dd == em)
94
            // Labour Day
95
0
            || (d == 1 && m == May)
96
            // Assumption
97
0
            || (d == 15 && m == August)
98
            // Christmas' Eve
99
0
            || (d == 24 && m == December)
100
            // Christmas
101
0
            || (d == 25 && m == December)
102
            // St. Stephen
103
0
            || (d == 26 && m == December)
104
            // New Year's Eve
105
0
            || (d == 31 && m == December))
106
0
            return false; // NOLINT(readability-simplify-boolean-expr)
107
0
        return true;
108
0
    }
109
110
}
111