/src/quantlib/ql/time/calendars/malta.cpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2026 SoftSolution 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/errors.hpp> |
21 | | #include <ql/time/calendars/malta.hpp> |
22 | | |
23 | | namespace QuantLib { |
24 | | |
25 | 0 | Malta::Malta(Market) { |
26 | 0 | static ext::shared_ptr<Calendar::Impl> impl(new Malta::MseImpl); |
27 | 0 | impl_ = impl; |
28 | 0 | } |
29 | | |
30 | 0 | bool Malta::MseImpl::isWeekend(Weekday w) const { |
31 | 0 | return w == Friday || w == Saturday; |
32 | 0 | } |
33 | | |
34 | 0 | bool Malta::MseImpl::isBusinessDay(const Date& date) const { |
35 | 0 | Weekday w = date.weekday(); |
36 | 0 | Day d = date.dayOfMonth(); |
37 | 0 | Month m = date.month(); |
38 | 0 | Year y = date.year(); |
39 | 0 | Day em = easterMonday(y); |
40 | 0 | Day gf = em - 3; // Good Friday |
41 | | |
42 | |
|
43 | 0 | if (isWeekend(w) |
44 | | // New Year's Day |
45 | 0 | || (d == 1 && m == January) |
46 | | // St. Paul's Shipwreck |
47 | 0 | || (d == 10 && m == February) |
48 | | // St. Joseph's Day |
49 | 0 | || (d == 19 && m == March) |
50 | | // Freedom Day |
51 | 0 | || (d == 31 && m == March) |
52 | | // Good Friday |
53 | 0 | || (date.dayOfYear() == gf) |
54 | | // Easter Monday (exchange holiday) |
55 | 0 | || (date.dayOfYear() == em) |
56 | | // Labour Day |
57 | 0 | || (d == 1 && m == May) |
58 | | // Imnarja (Feast of Saints Peter & Paul) |
59 | 0 | || (d == 29 && m == June) |
60 | | // Assumption of Mary |
61 | 0 | || (d == 15 && m == August) |
62 | | // Our Lady of Victories (Nativity of Mary) |
63 | 0 | || (d == 8 && m == September) |
64 | | // Independence Day |
65 | 0 | || (d == 21 && m == September) |
66 | | // Immaculate Conception |
67 | 0 | || (d == 8 && m == December) |
68 | | // Republic Day |
69 | 0 | || (d == 13 && m == December) |
70 | | // Christmas Vigil |
71 | 0 | || (d == 24 && m == December) |
72 | | // Christmas Day |
73 | 0 | || (d == 25 && m == December) |
74 | | // Boxing Day (occasionally observed by MSE) |
75 | 0 | || (d == 26 && m == December) |
76 | | // New Year's Eve (non-trading) |
77 | 0 | || (d == 31 && m == December)) |
78 | 0 | return false; |
79 | 0 | return true; |
80 | 0 | } |
81 | | |
82 | | } |