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

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