qofdate-p.h

00001 /********************************************************************
00002  *       qofdate-p.h - QofDate private header.
00003  *
00004  *  Tue Jun 13 16:19:13 2006
00005  *  Copyright (C) 2006 Free Software Foundation, Inc.
00006  ********************************************************************/
00007 /*
00008  * This program is free software; you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation; either version 2 of the License, or
00011  * (at your option) any later version.
00012  * 
00013  * This program is distributed in the hope that it will be useful,
00014  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00016  * GNU General Public License for more details.
00017  * 
00018  * You should have received a copy of the GNU General Public License
00019  * along with this program; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin Street, Fifth Floor Boston, MA 02110-1301,  USA
00021  */
00022  
00023 #ifndef _QOFDATE_P_H
00024 #define _QOFDATE_P_H
00025 
00026 #define ENUM_ERR_LIST(_)    \
00027     _(ERR_NO_ERROR, = 0)    \
00028     _(ERR_WEEKDAY_NAME,)    \
00029     _(ERR_MONTH_NAME,)      \
00030     _(ERR_LOCALE_DATE_TIME,) \
00031     _(ERR_STANDARD_DAY,)    \
00032     _(ERR_LOCALE_AMPM,)     \
00033     _(ERR_TIME_AMPM,)       \
00034     _(ERR_RECURSIVE_R,)     \
00035     _(ERR_SECS_NO_DIGITS,)  \
00036     _(ERR_RECURSIVE_T,)     \
00037     _(ERR_G_INCOMPLETE,)    \
00038     _(ERR_INVALID_Z,)       \
00039     _(ERR_YEAR_DIGITS,)     \
00040     _(ERR_MIN_TO_DECIMAL,)  \
00041     _(ERR_GMTOFF,)          \
00042     _(ERR_INVALID_FORMAT,)  \
00043     _(ERR_OUT_OF_RANGE,)    \
00044     _(ERR_INVALID_DELIMITER,) \
00045     _(ERR_INVALID_ERA,)     \
00046     _(ERR_UNKNOWN_ERR,)
00047 
00048 DEFINE_ENUM (QofDateError, ENUM_ERR_LIST)
00049 
00050 AS_STRING_DEC (QofDateError, ENUM_ERR_LIST)
00051 
00052 /* \brief QofDate private replacement for strftime
00053 
00054 (recursive).
00055 
00056  \param upcase used recursively to handle format specifiers
00057  that alter the case of the character to be generated.
00058  \param s  The buffer to hold the string being created.
00059  \param maxsize == MAX_DATE_BUFFER. Retained because of
00060  internal recursion.
00061  \param format The QofDateFormat string.
00062  \param qd The QofDate to parse.
00063  \param ut Use UTC if non-zero.
00064  \param ns Nanoseconds - for GNU %N extension.
00065 
00066  \return NULL on error or if the date is out of range
00067  of the specified format, otherwise the formatted string.
00068 */
00069 size_t
00070 strftime_case (gboolean upcase, gchar * s, size_t maxsize, 
00071     const gchar *format, const QofDate *qd, gint ut, glong ns);
00072 
00073 /* \brief QofDate replacement for strptime
00074 
00075 Returns a new QofDate from a string according to the 
00076 QofDateFormat specified. The QofDate becomes the 
00077 property of the caller and needs to be freed with
00078 qof_date_free when done.
00079 
00080  \note Locale-specific formats are not available for the full
00081 range of QofDate dates because the locale data for these
00082 formats is only available via the underlying strftime implementation.
00083 The formats affected are those involving the %E and %O modifiers 
00084 and other format specifiers that use the current locale. 
00085 e.g. Japanese Emperor reigns, local numeric specifiers etc. 
00086 If these are used, qofstrptime cannot support the full range
00087 because these implementations are not available to be extended.
00088 
00089 The full list of affected format specifiers is:
00090 
00091  \verbatim
00092  'a', 'A', 'b', 'h', 'B', 'c', 'C', 'x', 'p', 'P',
00093  'r', 'X', 'E' and 'O'.
00094  \endverbatim
00095 
00096  \param rp The string to parse.
00097  \param fmt The QofDateFormat format string.
00098  \param qd The empty QofDate structure to use. Any
00099  existing values are overwritten; the QofDate does \b not
00100  have to be valid.
00101  \param error Pointer to a QofDateError value to store
00102  any errors encountered during processing. Uses
00103  QofDateErrorasString to convert the code to a string for
00104  logging with QofLogLevel.
00105 
00106  \return If an error occurs, returns the remainder of the 
00107  string to parse and sets error. On success, returns NULL
00108  and sets error to ERR_NO_ERROR.
00109 */
00110 gchar *
00111 strptime_internal (const gchar * rp, const gchar * fmt, 
00112     QofDate * qd, QofDateError * error);
00113 
00114 /* get the number of days between 1st Jan of year1 
00115 and 1st Jan of year2. */
00116 gint64
00117 days_between (gint64 year1, gint64 year2);
00118 
00119 /* set the qd_wday of the QofDate */
00120 void
00121 set_day_of_the_week (QofDate * qd);
00122 
00123 #endif /* _QOFDATE_P_H */

Generated on Thu Jan 31 22:50:25 2008 for QOF by  doxygen 1.5.4