GnuCash  4.12-527-g05ffd3d4eb
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 extern "C"
35 {
36 #include "gnc-date.h"
37 }
38 
39 #include <vector>
40 #include <iostream>
47 enum class RelativeDatePeriod : int
48 {
49  ABSOLUTE = -1,
50  TODAY,
51  ONE_WEEK_AGO,
52  ONE_WEEK_AHEAD,
53  ONE_MONTH_AGO,
54  ONE_MONTH_AHEAD,
55  THREE_MONTHS_AGO,
56  THREE_MONTHS_AHEAD,
57  SIX_MONTHS_AGO,
58  SIX_MONTHS_AHEAD,
59  ONE_YEAR_AGO,
60  ONE_YEAR_AHEAD,
61  START_THIS_MONTH,
62  END_THIS_MONTH,
63  START_PREV_MONTH,
64  END_PREV_MONTH,
65  START_NEXT_MONTH,
66  END_NEXT_MONTH,
67  START_CURRENT_QUARTER,
68  END_CURRENT_QUARTER,
69  START_PREV_QUARTER,
70  END_PREV_QUARTER,
71  START_NEXT_QUARTER,
72  END_NEXT_QUARTER,
73  START_CAL_YEAR,
74  END_CAL_YEAR,
75  START_PREV_YEAR,
76  END_PREV_YEAR,
77  START_NEXT_YEAR,
78  END_NEXT_YEAR,
79  START_ACCOUNTING_PERIOD,
80  END_ACCOUNTING_PERIOD,
81 };
82 
83 constexpr unsigned relative_date_periods =
84  static_cast<unsigned>(RelativeDatePeriod::END_ACCOUNTING_PERIOD) + 2;
85 
86 using RelativeDatePeriodVec = std::vector<RelativeDatePeriod>;
87 
97 
106 
115 
127 
139 
150 
159 
176 
184 std::ostream& operator<<(std::ostream&, const RelativeDatePeriod);
185 
186 #endif //GNC_OPTION_DATE_HPP_
187 
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
Many systems, including Microsoft Windows and BSD-derived Unixes like Darwin, are retaining the int-3...
Definition: gnc-date.h:93