QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
weekday.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 Copyright (C) 2003, 2004, 2005, 2006 StatPro Italia srl
6 Copyright (C) 2004, 2005, 2006 Ferdinando Ametrano
7 Copyright (C) 2006 Katiuscia Manzoni
8 Copyright (C) 2006 Toyin Akin
9
10 This file is part of QuantLib, a free-software/open-source library
11 for financial quantitative analysts and developers - http://quantlib.org/
12
13 QuantLib is free software: you can redistribute it and/or modify it
14 under the terms of the QuantLib license. You should have received a
15 copy of the license along with this program; if not, please email
16 <quantlib-dev@lists.sf.net>. The license is also available online at
17 <http://quantlib.org/license.shtml>.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 FOR A PARTICULAR PURPOSE. See the license for more details.
22*/
23
24#include <ql/time/weekday.hpp>
25#include <ql/types.hpp>
26#include <ql/errors.hpp>
27
28namespace QuantLib {
29
30 // weekday formatting
31
32 std::ostream& operator<<(std::ostream& out, const Weekday& w) {
33 return out << io::long_weekday(w);
34 }
35
36 namespace detail {
37
38 std::ostream& operator<<(std::ostream& out,
39 const long_weekday_holder& holder) {
40 switch (holder.d) {
41 case Sunday:
42 return out << "Sunday";
43 case Monday:
44 return out << "Monday";
45 case Tuesday:
46 return out << "Tuesday";
47 case Wednesday:
48 return out << "Wednesday";
49 case Thursday:
50 return out << "Thursday";
51 case Friday:
52 return out << "Friday";
53 case Saturday:
54 return out << "Saturday";
55 default:
56 QL_FAIL("unknown weekday");
57 }
58 }
59
60 std::ostream& operator<<(std::ostream& out,
61 const short_weekday_holder& holder) {
62 switch (holder.d) {
63 case Sunday:
64 return out << "Sun";
65 case Monday:
66 return out << "Mon";
67 case Tuesday:
68 return out << "Tue";
69 case Wednesday:
70 return out << "Wed";
71 case Thursday:
72 return out << "Thu";
73 case Friday:
74 return out << "Fri";
75 case Saturday:
76 return out << "Sat";
77 default:
78 QL_FAIL("unknown weekday");
79 }
80 }
81
82 std::ostream& operator<<(std::ostream& out,
83 const shortest_weekday_holder& holder) {
84 switch (holder.d) {
85 case Sunday:
86 return out << "Su";
87 case Monday:
88 return out << "Mo";
89 case Tuesday:
90 return out << "Tu";
91 case Wednesday:
92 return out << "We";
93 case Thursday:
94 return out << "Th";
95 case Friday:
96 return out << "Fr";
97 case Saturday:
98 return out << "Sa";
99 default:
100 QL_FAIL("unknown weekday");
101 }
102 }
103
104 }
105
106 namespace io {
107
110 }
111
114 }
115
118 }
119
120 }
121
122}
Classes and functions for error handling.
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Definition: errors.hpp:92
Date d
@ Wednesday
Definition: weekday.hpp:44
@ Monday
Definition: weekday.hpp:42
@ Sunday
Definition: weekday.hpp:41
@ Tuesday
Definition: weekday.hpp:43
@ Saturday
Definition: weekday.hpp:47
@ Thursday
Definition: weekday.hpp:45
@ Friday
Definition: weekday.hpp:46
detail::shortest_weekday_holder shortest_weekday(Weekday)
output weekdays in shortest format (two letters)
Definition: weekday.cpp:116
detail::long_weekday_holder long_weekday(Weekday)
output weekdays in long format
Definition: weekday.cpp:108
detail::short_weekday_holder short_weekday(Weekday)
output weekdays in short format (three letters)
Definition: weekday.cpp:112
std::ostream & operator<<(std::ostream &out, const short_date_holder &holder)
Definition: date.cpp:894
Definition: any.hpp:35
std::ostream & operator<<(std::ostream &out, GFunctionFactory::YieldCurveModel type)
Custom types.
Weekday enumeration.