QOF: qofdate-p.h Source File

QOF 0.7.5

qofdate-p.h
1 /********************************************************************
2 * qofdate-p.h - QofDate private header.
3 *
4 * Tue Jun 13 16:19:13 2006
5 * Copyright (C) 2006 Free Software Foundation, Inc.
6 ********************************************************************/
7 /*
8 * This program is free software; you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation; either version 2 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301, USA
21 */
22
23 #ifndef _QOFDATE_P_H
24 #define _QOFDATE_P_H
25
26 #define ENUM_ERR_LIST(_) \
27 _(ERR_NO_ERROR, = 0) \
28 _(ERR_WEEKDAY_NAME,) \
29 _(ERR_MONTH_NAME,) \
30 _(ERR_LOCALE_DATE_TIME,) \
31 _(ERR_STANDARD_DAY,) \
32 _(ERR_LOCALE_AMPM,) \
33 _(ERR_TIME_AMPM,) \
34 _(ERR_RECURSIVE_R,) \
35 _(ERR_SECS_NO_DIGITS,) \
36 _(ERR_RECURSIVE_T,) \
37 _(ERR_G_INCOMPLETE,) \
38 _(ERR_INVALID_Z,) \
39 _(ERR_YEAR_DIGITS,) \
40 _(ERR_MIN_TO_DECIMAL,) \
41 _(ERR_GMTOFF,) \
42 _(ERR_INVALID_FORMAT,) \
43 _(ERR_OUT_OF_RANGE,) \
44 _(ERR_INVALID_DELIMITER,) \
45 _(ERR_INVALID_ERA,) \
46 _(ERR_UNKNOWN_ERR,)
47
48 DEFINE_ENUM (QofDateError, ENUM_ERR_LIST)
49
50 AS_STRING_DEC (QofDateError, ENUM_ERR_LIST)
51
52 /* \brief QofDate private replacement for strftime
53
54 (recursive).
55
56 \param upcase used recursively to handle format specifiers
57 that alter the case of the character to be generated.
58 \param s The buffer to hold the string being created.
59 \param maxsize == MAX_DATE_BUFFER. Retained because of
60 internal recursion.
61 \param format The QofDateFormat string.
62 \param qd The QofDate to parse.
63 \param ut Use UTC if non-zero.
64 \param ns Nanoseconds - for GNU %N extension.
65
66 \return NULL on error or if the date is out of range
67 of the specified format, otherwise the formatted string.
68 */
69 size_t
70 strftime_case (gboolean upcase, gchar * s, size_t maxsize,
71 const gchar *format, const QofDate *qd, gint ut, glong ns);
72
73 /* \brief QofDate replacement for strptime
74
75 Returns a new QofDate from a string according to the
76 QofDateFormat specified. The QofDate becomes the
77 property of the caller and needs to be freed with
78 qof_date_free when done.
79
80 \note Locale-specific formats are not available for the full
81 range of QofDate dates because the locale data for these
82 formats is only available via the underlying strftime implementation.
83 The formats affected are those involving the %E and %O modifiers
84 and other format specifiers that use the current locale.
85 e.g. Japanese Emperor reigns, local numeric specifiers etc.
86 If these are used, qofstrptime cannot support the full range
87 because these implementations are not available to be extended.
88
89 The full list of affected format specifiers is:
90
91 \verbatim
92 'a', 'A', 'b', 'h', 'B', 'c', 'C', 'x', 'p', 'P',
93 'r', 'X', 'E' and 'O'.
94 \endverbatim
95
96 \param rp The string to parse.
97 \param fmt The QofDateFormat format string.
98 \param qd The empty QofDate structure to use. Any
99 existing values are overwritten; the QofDate does \b not
100 have to be valid.
101 \param error Pointer to a QofDateError value to store
102 any errors encountered during processing. Uses
103 QofDateErrorasString to convert the code to a string for
104 logging with QofLogLevel.
105
106 \return If an error occurs, returns the remainder of the
107 string to parse and sets error. On success, returns NULL
108 and sets error to ERR_NO_ERROR.
109 */
110 gchar *
111 strptime_internal (const gchar * rp, const gchar * fmt,
112 QofDate * qd, QofDateError * error);
113
114 /* get the number of days between 1st Jan of year1
115 and 1st Jan of year2. */
116 gint64
117 days_between (gint64 year1, gint64 year2);
118
119 /* set the qd_wday of the QofDate */
120 void
121 set_day_of_the_week (QofDate * qd);
122
123 #endif /* _QOFDATE_P_H */
QofDate_s
Full range replacement for struct tm.
Definition: qofdate.h:138