* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the
- * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
- * Boston, MA 02111-1307, USA.
+ * License along with this library; if not, see <http://www.gnu.org/licenses/>.
*/
/*
* GLib at ftp://ftp.gtk.org/pub/gtk/.
*/
-#if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
-#error "Only <glib.h> can be included directly."
-#endif
-
#ifndef __G_DATE_H__
#define __G_DATE_H__
+#if !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
+#error "Only <glib.h> can be included directly."
+#endif
+
#include <time.h>
#include <glib/gtypes.h>
* to get a usable object. You can also allocate a GDate statically,
* then call g_date_clear() to initialize.
*/
+GLIB_AVAILABLE_IN_ALL
GDate* g_date_new (void);
+GLIB_AVAILABLE_IN_ALL
GDate* g_date_new_dmy (GDateDay day,
GDateMonth month,
GDateYear year);
+GLIB_AVAILABLE_IN_ALL
GDate* g_date_new_julian (guint32 julian_day);
+GLIB_AVAILABLE_IN_ALL
void g_date_free (GDate *date);
/* check g_date_valid() after doing an operation that might fail, like
* dates (the exceptions are the mutators, since you need those to
* return to validity).
*/
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_valid (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_valid_day (GDateDay day) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_valid_month (GDateMonth month) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_valid_year (GDateYear year) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_valid_weekday (GDateWeekday weekday) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_valid_julian (guint32 julian_date) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_valid_dmy (GDateDay day,
GDateMonth month,
GDateYear year) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
GDateWeekday g_date_get_weekday (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
GDateMonth g_date_get_month (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
GDateYear g_date_get_year (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
GDateDay g_date_get_day (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
guint32 g_date_get_julian (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
guint g_date_get_day_of_year (const GDate *date);
/* First monday/sunday is the start of week 1; if we haven't reached
* that day, return 0. These are not ISO weeks of the year; that
* these functions return the number of weeks, starting on the
* corrsponding day
*/
+GLIB_AVAILABLE_IN_ALL
guint g_date_get_monday_week_of_year (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
guint g_date_get_sunday_week_of_year (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
guint g_date_get_iso8601_week_of_year (const GDate *date);
/* If you create a static date struct you need to clear it to get it
* in a sane state before use. You can clear a whole array at
* once with the ndates argument.
*/
+GLIB_AVAILABLE_IN_ALL
void g_date_clear (GDate *date,
guint n_dates);
* permits many formats but tries to catch common typos. If your data
* needs to be strictly validated, it is not an appropriate function.
*/
+GLIB_AVAILABLE_IN_ALL
void g_date_set_parse (GDate *date,
const gchar *str);
+GLIB_AVAILABLE_IN_ALL
void g_date_set_time_t (GDate *date,
time_t timet);
+GLIB_AVAILABLE_IN_ALL
void g_date_set_time_val (GDate *date,
GTimeVal *timeval);
#ifndef G_DISABLE_DEPRECATED
+GLIB_DEPRECATED_FOR(g_date_set_time_t)
void g_date_set_time (GDate *date,
GTime time_);
#endif
+GLIB_AVAILABLE_IN_ALL
void g_date_set_month (GDate *date,
GDateMonth month);
+GLIB_AVAILABLE_IN_ALL
void g_date_set_day (GDate *date,
GDateDay day);
+GLIB_AVAILABLE_IN_ALL
void g_date_set_year (GDate *date,
GDateYear year);
+GLIB_AVAILABLE_IN_ALL
void g_date_set_dmy (GDate *date,
GDateDay day,
GDateMonth month,
GDateYear y);
+GLIB_AVAILABLE_IN_ALL
void g_date_set_julian (GDate *date,
guint32 julian_date);
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_is_first_of_month (const GDate *date);
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_is_last_of_month (const GDate *date);
/* To go forward by some number of weeks just go forward weeks*7 days */
+GLIB_AVAILABLE_IN_ALL
void g_date_add_days (GDate *date,
guint n_days);
+GLIB_AVAILABLE_IN_ALL
void g_date_subtract_days (GDate *date,
guint n_days);
/* If you add/sub months while day > 28, the day might change */
+GLIB_AVAILABLE_IN_ALL
void g_date_add_months (GDate *date,
guint n_months);
+GLIB_AVAILABLE_IN_ALL
void g_date_subtract_months (GDate *date,
guint n_months);
/* If it's feb 29, changing years can move you to the 28th */
+GLIB_AVAILABLE_IN_ALL
void g_date_add_years (GDate *date,
guint n_years);
+GLIB_AVAILABLE_IN_ALL
void g_date_subtract_years (GDate *date,
guint n_years);
+GLIB_AVAILABLE_IN_ALL
gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
guint8 g_date_get_days_in_month (GDateMonth month,
GDateYear year) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST;
+GLIB_AVAILABLE_IN_ALL
guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST;
/* Returns the number of days between the two dates. If date2 comes
before date1, a negative value is return. */
+GLIB_AVAILABLE_IN_ALL
gint g_date_days_between (const GDate *date1,
const GDate *date2);
/* qsort-friendly (with a cast...) */
+GLIB_AVAILABLE_IN_ALL
gint g_date_compare (const GDate *lhs,
const GDate *rhs);
+GLIB_AVAILABLE_IN_ALL
void g_date_to_struct_tm (const GDate *date,
struct tm *tm);
+GLIB_AVAILABLE_IN_ALL
void g_date_clamp (GDate *date,
const GDate *min_date,
const GDate *max_date);
/* Swap date1 and date2's values if date1 > date2. */
+GLIB_AVAILABLE_IN_ALL
void g_date_order (GDate *date1, GDate *date2);
/* Just like strftime() except you can only use date-related formats.
* Using a time format is undefined.
*/
+GLIB_AVAILABLE_IN_ALL
gsize g_date_strftime (gchar *s,
gsize slen,
const gchar *format,