Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
unitedarabemirates.cpp
Go to the documentation of this file.
1/*
2Copyright (C) 2022 Quaternion Risk Management Ltd
3All rights reserved.
4
5This file is part of ORE, a free-software/open-source library
6for transparent pricing and risk analysis - http://opensourcerisk.org
7
8ORE is free software: you can redistribute it and/or modify it
9under the terms of the Modified BSD License. You should have received a
10copy of the license along with this program.
11The license is also available online at <http://opensourcerisk.org>
12
13This program is distributed on the basis that it will form a useful
14contribution to risk analytics and model standardisation, but WITHOUT
15ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
20namespace {
21bool isTrueWeekend(QuantLib::Date d) {
22 // The UAE weekend was changed from 1st Jan 2022
23 auto w = d.weekday();
24 return (d < QuantLib::Date(1, QuantLib::Jan, 2022)) ?
25 (w == QuantLib::Friday || w == QuantLib::Saturday) :
26 (w == QuantLib::Saturday || w == QuantLib::Sunday);
27}
28}
29namespace QuantExt {
31 // all calendar instances share the same implementation instance
32 static ext::shared_ptr<Calendar::Impl> impl(new UnitedArabEmirates::Impl);
33 impl_ = impl;
34}
35
36bool UnitedArabEmirates::Impl::isWeekend(QuantLib::Weekday w) const {
37 return w == QuantLib::Saturday || w == QuantLib::Sunday ;
38}
39
40bool UnitedArabEmirates::Impl::isBusinessDay(const QuantLib::Date& d) const {
41 Day n = d.dayOfMonth();
42 Month m = d.month();
43
44 if (isTrueWeekend(d) ||
45 (n==1 && m == Jan) || // Gregorian new year
46 (n==2 && m == Dec)) // National Day
47 return false;
48 else
49 return true;
50}
51}
bool isBusinessDay(const Date &) const override
bool isWeekend(Weekday) const override