Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/time/calendars/france.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) 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/france.hpp>
21
#include <ql/errors.hpp>
22
23
namespace QuantLib {
24
25
0
    France::France(France::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 France::SettlementImpl);
30
0
        static ext::shared_ptr<Calendar::Impl> exchangeImpl(
31
0
                                                   new France::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 France::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
            // Jour de l'An
53
0
            || (d == 1 && m == January)
54
            // Lundi de Paques
55
0
            || (dd == em)
56
            // Fete du Travail
57
0
            || (d == 1 && m == May)
58
            // Victoire 1945
59
0
            || (d == 8 && m == May)
60
            // Ascension
61
0
            || (d == 10 && m == May)
62
            // Pentecote
63
0
            || (d == 21 && m == May)
64
            // Fete nationale
65
0
            || (d == 14 && m == July)
66
            // Assomption
67
0
            || (d == 15 && m == August)
68
            // Toussaint
69
0
            || (d == 1 && m == November)
70
            // Armistice 1918
71
0
            || (d == 11 && m == November)
72
            // Noel
73
0
            || (d == 25 && m == December))
74
            
75
0
            return false; // NOLINT(readability-simplify-boolean-expr)
76
0
        return true;
77
0
    }
78
79
80
0
    bool France::ExchangeImpl::isBusinessDay(const Date& date) const {
81
0
        Weekday w = date.weekday();
82
0
        Day d = date.dayOfMonth(), dd = date.dayOfYear();
83
0
        Month m = date.month();
84
0
        Year y = date.year();
85
0
        Day em = easterMonday(y);
86
0
        if (isWeekend(w)
87
            // Jour de l'An
88
0
            || (d == 1 && m == January)
89
            // Good Friday
90
0
            || (dd == em-3)
91
            // Easter Monday
92
0
            || (dd == em)
93
            // Labor Day
94
0
            || (d == 1 && m == May)
95
            // Christmas Eve
96
0
            || (d == 24 && m == December)
97
            // Christmas Day
98
0
            || (d == 25 && m == December)
99
            // Boxing Day
100
0
            || (d == 26 && m == December)
101
            // New Year's Eve
102
0
            || (d == 31 && m == December))
103
         
104
0
            return false; // NOLINT(readability-simplify-boolean-expr)
105
0
        return true;
106
0
    }
107
108
}
109