QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
newzealand.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap 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
21
22namespace QuantLib {
23
25 // all calendar instances share the same implementation instance
26 static ext::shared_ptr<Calendar::Impl> impl(new NewZealand::Impl);
27 impl_ = impl;
28 }
29
30 bool NewZealand::Impl::isBusinessDay(const Date& date) const {
31 Weekday w = date.weekday();
32 Day d = date.dayOfMonth(), dd = date.dayOfYear();
33 Month m = date.month();
34 Year y = date.year();
35 Day em = easterMonday(y);
36 if (isWeekend(w)
37 // New Year's Day (possibly moved to Monday or Tuesday)
38 || ((d == 1 || (d == 3 && (w == Monday || w == Tuesday))) &&
39 m == January)
40 // Day after New Year's Day (possibly moved to Mon or Tuesday)
41 || ((d == 2 || (d == 4 && (w == Monday || w == Tuesday))) &&
42 m == January)
43 // Anniversary Day, Monday nearest January 22nd
44 || ((d >= 19 && d <= 25) && w == Monday && m == January)
45 // Waitangi Day. February 6th ("Mondayised" since 2013)
46 || (d == 6 && m == February)
47 || ((d == 7 || d == 8) && w == Monday && m == February && y > 2013)
48 // Good Friday
49 || (dd == em-3)
50 // Easter Monday
51 || (dd == em)
52 // ANZAC Day. April 25th ("Mondayised" since 2013)
53 || (d == 25 && m == April)
54 || ((d == 26 || d == 27) && w == Monday && m == April && y > 2013)
55 // Queen's Birthday, first Monday in June
56 || (d <= 7 && w == Monday && m == June)
57 // Labour Day, fourth Monday in October
58 || ((d >= 22 && d <= 28) && w == Monday && m == October)
59 // Christmas, December 25th (possibly Monday or Tuesday)
60 || ((d == 25 || (d == 27 && (w == Monday || w == Tuesday)))
61 && m == December)
62 // Boxing Day, December 26th (possibly Monday or Tuesday)
63 || ((d == 26 || (d == 28 && (w == Monday || w == Tuesday)))
64 && m == December)
65 // Matariki, it happens on Friday in June or July
66 // official calendar released by the NZ government for the
67 // next 30 years
68 || (d == 20 && m == June && y == 2025)
69 || (d == 21 && m == June && (y == 2030 || y == 2052))
70 || (d == 24 && m == June && (y == 2022 || y == 2033 || y == 2044))
71 || (d == 25 && m == June && (y == 2027 || y == 2038 || y == 2049))
72 || (d == 28 && m == June && y == 2024)
73 || (d == 29 && m == June && (y == 2035 || y == 2046))
74 || (d == 30 && m == June && y == 2051)
75 || (d == 2 && m == July && y == 2032)
76 || (d == 3 && m == July && (y == 2043 || y == 2048))
77 || (d == 6 && m == July && (y == 2029 || y == 2040))
78 || (d == 7 && m == July && (y == 2034 || y == 2045))
79 || (d == 10 && m == July && (y == 2026 || y == 2037))
80 || (d == 11 && m == July && (y == 2031 || y == 2042))
81 || (d == 14 && m == July && (y == 2023 || y == 2028))
82 || (d == 15 && m == July && (y == 2039 || y == 2050))
83 || (d == 18 && m == July && y == 2036)
84 || (d == 19 && m == July && (y == 2041 || y == 2047)))
85 return false; // NOLINT(readability-simplify-boolean-expr)
86 return true;
87 }
88
89}
static Day easterMonday(Year)
expressed relative to first day of year
Definition: calendar.cpp:199
bool isWeekend(Weekday) const override
Definition: calendar.cpp:195
ext::shared_ptr< Impl > impl_
Definition: calendar.hpp:72
Concrete date class.
Definition: date.hpp:125
Month month() const
Definition: date.cpp:82
Year year() const
Definition: date.cpp:93
Day dayOfMonth() const
Definition: date.hpp:400
Weekday weekday() const
Definition: date.hpp:395
Day dayOfYear() const
One-based (Jan 1st = 1)
Definition: date.hpp:404
bool isBusinessDay(const Date &) const override
Definition: newzealand.cpp:30
Date d
Integer Year
Year number.
Definition: date.hpp:87
Integer Day
Day number.
Definition: date.hpp:53
Month
Month names.
Definition: date.hpp:57
@ December
Definition: date.hpp:68
@ January
Definition: date.hpp:57
@ July
Definition: date.hpp:63
@ February
Definition: date.hpp:58
@ April
Definition: date.hpp:60
@ October
Definition: date.hpp:66
@ June
Definition: date.hpp:62
@ Monday
Definition: weekday.hpp:42
@ Tuesday
Definition: weekday.hpp:43
Definition: any.hpp:35
New Zealand calendar.