GnuCash  5.6-150-g038405b370+
gnc-option-date.hpp
Go to the documentation of this file.
1 /********************************************************************\
2  * gnc-option-date.hpp -- Relative dates for options *
3  * Copyright (C) 2020 John Ralls <jralls@ceridwen.us> *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA gnu@gnu.org *
21  * *
22 \********************************************************************/
31 #ifndef GNC_OPTION_DATE_HPP_
32 #define GNC_OPTION_DATE_HPP_
33 
34 #include "gnc-date.h"
35 
36 #include <vector>
37 #include <iostream>
44 enum class RelativeDatePeriod : int
45 {
46  ABSOLUTE = -1,
47  TODAY,
48  ONE_WEEK_AGO,
49  ONE_WEEK_AHEAD,
50  ONE_MONTH_AGO,
51  ONE_MONTH_AHEAD,
52  THREE_MONTHS_AGO,
53  THREE_MONTHS_AHEAD,
54  SIX_MONTHS_AGO,
55  SIX_MONTHS_AHEAD,
56  ONE_YEAR_AGO,
57  ONE_YEAR_AHEAD,
58  START_THIS_MONTH,
59  END_THIS_MONTH,
60  START_PREV_MONTH,
61  END_PREV_MONTH,
62  START_NEXT_MONTH,
63  END_NEXT_MONTH,
64  START_CURRENT_QUARTER,
65  END_CURRENT_QUARTER,
66  START_PREV_QUARTER,
67  END_PREV_QUARTER,
68  START_NEXT_QUARTER,
69  END_NEXT_QUARTER,
70  START_CAL_YEAR,
71  END_CAL_YEAR,
72  START_PREV_YEAR,
73  END_PREV_YEAR,
74  START_NEXT_YEAR,
75  END_NEXT_YEAR,
76  START_ACCOUNTING_PERIOD,
77  END_ACCOUNTING_PERIOD,
78 };
79 
80 constexpr unsigned relative_date_periods =
81  static_cast<unsigned>(RelativeDatePeriod::END_ACCOUNTING_PERIOD) + 2;
82 
83 using RelativeDatePeriodVec = std::vector<RelativeDatePeriod>;
84 
94 
103 
112 
124 
136 
147 
156 
173 
181 std::ostream& operator<<(std::ostream&, const RelativeDatePeriod);
182 
183 #endif //GNC_OPTION_DATE_HPP_
184 
std::ostream & operator<<(std::ostream &, const RelativeDatePeriod)
Add the display string to the provided std::ostream.
RelativeDatePeriod gnc_relative_date_from_storage_string(const char *)
Convert a relative date storage string back to a RelativeDatePeriod value.
const char * gnc_relative_date_display_string(RelativeDatePeriod)
Provide the string representation of a relative date for displaying value to a user.
Date and Time handling routines.
const char * gnc_relative_date_description(RelativeDatePeriod)
Provide the description of a relative date.
time64 gnc_relative_date_to_time64(RelativeDatePeriod)
Convert a RelativeDatePeriod value to a concrete time64 by applying the value to the current time...
bool gnc_relative_date_is_ending(RelativeDatePeriod)
Report whether the relative date represents the end of a date range.
bool gnc_relative_date_is_single(RelativeDatePeriod)
Report whether the relative date represents a period offset to today&#39;s date rather than the beginning...
RelativeDatePeriod
Reporting periods relative to the current date.
bool gnc_relative_date_is_starting(RelativeDatePeriod)
Report whether the relative date represents the beginning of a date range.
const char * gnc_relative_date_storage_string(RelativeDatePeriod)
Provide the string representation of a relative date for persisting the value.
gint64 time64
Most systems that are currently maintained, including Microsoft Windows, BSD-derived Unixes and Linux...
Definition: gnc-date.h:87