1.1 --- a/epoc32/include/stdapis/glib-2.0/glib/gdate.h Tue Nov 24 13:55:44 2009 +0000
1.2 +++ b/epoc32/include/stdapis/glib-2.0/glib/gdate.h Tue Mar 16 16:12:26 2010 +0000
1.3 @@ -1,1 +1,264 @@
1.4 -gdate.h
1.5 +/* GLIB - Library of useful routines for C programming
1.6 + * Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
1.7 + * Portions copyright (c) 2006 Nokia Corporation. All rights reserved.
1.8 + *
1.9 + * This library is free software; you can redistribute it and/or
1.10 + * modify it under the terms of the GNU Lesser General Public
1.11 + * License as published by the Free Software Foundation; either
1.12 + * version 2 of the License, or (at your option) any later version.
1.13 + *
1.14 + * This library is distributed in the hope that it will be useful,
1.15 + * but WITHOUT ANY WARRANTY; without even the implied warranty of
1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
1.17 + * Lesser General Public License for more details.
1.18 + *
1.19 + * You should have received a copy of the GNU Lesser General Public
1.20 + * License along with this library; if not, write to the
1.21 + * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
1.22 + * Boston, MA 02111-1307, USA.
1.23 + */
1.24 +
1.25 +/*
1.26 + * Modified by the GLib Team and others 1997-2000. See the AUTHORS
1.27 + * file for a list of people on the GLib Team. See the ChangeLog
1.28 + * files for a list of changes. These files are distributed with
1.29 + * GLib at ftp://ftp.gtk.org/pub/gtk/.
1.30 + */
1.31 +
1.32 +#ifndef __G_DATE_H__
1.33 +#define __G_DATE_H__
1.34 +
1.35 +#include <_ansi.h>
1.36 +#include <time.h>
1.37 +
1.38 +#include <glib/gtypes.h>
1.39 +#include <glib/gquark.h>
1.40 +
1.41 +G_BEGIN_DECLS
1.42 +
1.43 +/* GDate
1.44 + *
1.45 + * Date calculations (not time for now, to be resolved). These are a
1.46 + * mutant combination of Steffen Beyer's DateCalc routines
1.47 + * (http://www.perl.com/CPAN/authors/id/STBEY/) and Jon Trowbridge's
1.48 + * date routines (written for in-house software). Written by Havoc
1.49 + * Pennington <hp@pobox.com>
1.50 + */
1.51 +
1.52 +typedef gint32 GTime;
1.53 +typedef guint16 GDateYear;
1.54 +typedef guint8 GDateDay; /* day of the month */
1.55 +typedef struct _GDate GDate;
1.56 +/* make struct tm known without having to include time.h */
1.57 +struct tm;
1.58 +
1.59 +/* enum used to specify order of appearance in parsed date strings */
1.60 +typedef enum
1.61 +{
1.62 + G_DATE_DAY = 0,
1.63 + G_DATE_MONTH = 1,
1.64 + G_DATE_YEAR = 2
1.65 +} GDateDMY;
1.66 +
1.67 +/* actual week and month values */
1.68 +typedef enum
1.69 +{
1.70 + G_DATE_BAD_WEEKDAY = 0,
1.71 + G_DATE_MONDAY = 1,
1.72 + G_DATE_TUESDAY = 2,
1.73 + G_DATE_WEDNESDAY = 3,
1.74 + G_DATE_THURSDAY = 4,
1.75 + G_DATE_FRIDAY = 5,
1.76 + G_DATE_SATURDAY = 6,
1.77 + G_DATE_SUNDAY = 7
1.78 +} GDateWeekday;
1.79 +typedef enum
1.80 +{
1.81 + G_DATE_BAD_MONTH = 0,
1.82 + G_DATE_JANUARY = 1,
1.83 + G_DATE_FEBRUARY = 2,
1.84 + G_DATE_MARCH = 3,
1.85 + G_DATE_APRIL = 4,
1.86 + G_DATE_MAY = 5,
1.87 + G_DATE_JUNE = 6,
1.88 + G_DATE_JULY = 7,
1.89 + G_DATE_AUGUST = 8,
1.90 + G_DATE_SEPTEMBER = 9,
1.91 + G_DATE_OCTOBER = 10,
1.92 + G_DATE_NOVEMBER = 11,
1.93 + G_DATE_DECEMBER = 12
1.94 +} GDateMonth;
1.95 +
1.96 +#define G_DATE_BAD_JULIAN 0U
1.97 +#define G_DATE_BAD_DAY 0U
1.98 +#define G_DATE_BAD_YEAR 0U
1.99 +
1.100 +/* Note: directly manipulating structs is generally a bad idea, but
1.101 + * in this case it's an *incredibly* bad idea, because all or part
1.102 + * of this struct can be invalid at any given time. Use the functions,
1.103 + * or you will get hosed, I promise.
1.104 + */
1.105 +struct _GDate
1.106 +{
1.107 + guint julian_days : 32; /* julian days representation - we use a
1.108 + * bitfield hoping that 64 bit platforms
1.109 + * will pack this whole struct in one big
1.110 + * int
1.111 + */
1.112 +
1.113 + guint julian : 1; /* julian is valid */
1.114 + guint dmy : 1; /* dmy is valid */
1.115 +
1.116 + /* DMY representation */
1.117 + guint day : 6;
1.118 + guint month : 4;
1.119 + guint year : 16;
1.120 +};
1.121 +
1.122 +/* g_date_new() returns an invalid date, you then have to _set() stuff
1.123 + * to get a usable object. You can also allocate a GDate statically,
1.124 + * then call g_date_clear() to initialize.
1.125 + */
1.126 +IMPORT_C GDate* g_date_new (void);
1.127 +IMPORT_C GDate* g_date_new_dmy (GDateDay day,
1.128 + GDateMonth month,
1.129 + GDateYear year);
1.130 +IMPORT_C GDate* g_date_new_julian (guint32 julian_day);
1.131 +IMPORT_C void g_date_free (GDate *date);
1.132 +
1.133 +/* check g_date_valid() after doing an operation that might fail, like
1.134 + * _parse. Almost all g_date operations are undefined on invalid
1.135 + * dates (the exceptions are the mutators, since you need those to
1.136 + * return to validity).
1.137 + */
1.138 +IMPORT_C gboolean g_date_valid (const GDate *date);
1.139 +IMPORT_C gboolean g_date_valid_day (GDateDay day) G_GNUC_CONST;
1.140 +IMPORT_C gboolean g_date_valid_month (GDateMonth month) G_GNUC_CONST;
1.141 +IMPORT_C gboolean g_date_valid_year (GDateYear year) G_GNUC_CONST;
1.142 +IMPORT_C gboolean g_date_valid_weekday (GDateWeekday weekday) G_GNUC_CONST;
1.143 +IMPORT_C gboolean g_date_valid_julian (guint32 julian_date) G_GNUC_CONST;
1.144 +IMPORT_C gboolean g_date_valid_dmy (GDateDay day,
1.145 + GDateMonth month,
1.146 + GDateYear year) G_GNUC_CONST;
1.147 +
1.148 +IMPORT_C GDateWeekday g_date_get_weekday (const GDate *date);
1.149 +IMPORT_C GDateMonth g_date_get_month (const GDate *date);
1.150 +IMPORT_C GDateYear g_date_get_year (const GDate *date);
1.151 +IMPORT_C GDateDay g_date_get_day (const GDate *date);
1.152 +IMPORT_C guint32 g_date_get_julian (const GDate *date);
1.153 +IMPORT_C guint g_date_get_day_of_year (const GDate *date);
1.154 +/* First monday/sunday is the start of week 1; if we haven't reached
1.155 + * that day, return 0. These are not ISO weeks of the year; that
1.156 + * routine needs to be added.
1.157 + * these functions return the number of weeks, starting on the
1.158 + * corrsponding day
1.159 + */
1.160 +IMPORT_C guint g_date_get_monday_week_of_year (const GDate *date);
1.161 +IMPORT_C guint g_date_get_sunday_week_of_year (const GDate *date);
1.162 +IMPORT_C guint g_date_get_iso8601_week_of_year (const GDate *date);
1.163 +
1.164 +/* If you create a static date struct you need to clear it to get it
1.165 + * in a sane state before use. You can clear a whole array at
1.166 + * once with the ndates argument.
1.167 + */
1.168 +IMPORT_C void g_date_clear (GDate *date,
1.169 + guint n_dates);
1.170 +
1.171 +/* The parse routine is meant for dates typed in by a user, so it
1.172 + * permits many formats but tries to catch common typos. If your data
1.173 + * needs to be strictly validated, it is not an appropriate function.
1.174 + */
1.175 +IMPORT_C void g_date_set_parse (GDate *date,
1.176 + const gchar *str);
1.177 +IMPORT_C void g_date_set_time (GDate *date,
1.178 + time_t timet);
1.179 +IMPORT_C void g_date_set_time_val (GDate *date,
1.180 + GTimeVal *timeval);
1.181 +#ifndef G_DISABLE_DEPRECATED
1.182 +IMPORT_C void g_date_set_time (GDate *date,
1.183 + GTime time_);
1.184 +#endif
1.185 +IMPORT_C void g_date_set_month (GDate *date,
1.186 + GDateMonth month);
1.187 +IMPORT_C void g_date_set_day (GDate *date,
1.188 + GDateDay day);
1.189 +IMPORT_C void g_date_set_year (GDate *date,
1.190 + GDateYear year);
1.191 +IMPORT_C void g_date_set_dmy (GDate *date,
1.192 + GDateDay day,
1.193 + GDateMonth month,
1.194 + GDateYear y);
1.195 +IMPORT_C void g_date_set_julian (GDate *date,
1.196 + guint32 julian_date);
1.197 +IMPORT_C gboolean g_date_is_first_of_month (const GDate *date);
1.198 +IMPORT_C gboolean g_date_is_last_of_month (const GDate *date);
1.199 +
1.200 +/* To go forward by some number of weeks just go forward weeks*7 days */
1.201 +IMPORT_C void g_date_add_days (GDate *date,
1.202 + guint n_days);
1.203 +IMPORT_C void g_date_subtract_days (GDate *date,
1.204 + guint n_days);
1.205 +
1.206 +/* If you add/sub months while day > 28, the day might change */
1.207 +IMPORT_C void g_date_add_months (GDate *date,
1.208 + guint n_months);
1.209 +IMPORT_C void g_date_subtract_months (GDate *date,
1.210 + guint n_months);
1.211 +
1.212 +/* If it's feb 29, changing years can move you to the 28th */
1.213 +IMPORT_C void g_date_add_years (GDate *date,
1.214 + guint n_years);
1.215 +IMPORT_C void g_date_subtract_years (GDate *date,
1.216 + guint n_years);
1.217 +IMPORT_C gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST;
1.218 +IMPORT_C guint8 g_date_get_days_in_month (GDateMonth month,
1.219 + GDateYear year) G_GNUC_CONST;
1.220 +IMPORT_C guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST;
1.221 +IMPORT_C guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST;
1.222 +
1.223 +/* Returns the number of days between the two dates. If date2 comes
1.224 + before date1, a negative value is return. */
1.225 +IMPORT_C gint g_date_days_between (const GDate *date1,
1.226 + const GDate *date2);
1.227 +
1.228 +/* qsort-friendly (with a cast...) */
1.229 +IMPORT_C gint g_date_compare (const GDate *lhs,
1.230 + const GDate *rhs);
1.231 +IMPORT_C void g_date_to_struct_tm (const GDate *date,
1.232 + struct tm *tm);
1.233 +
1.234 +IMPORT_C void g_date_clamp (GDate *date,
1.235 + const GDate *min_date,
1.236 + const GDate *max_date);
1.237 +
1.238 +/* Swap date1 and date2's values if date1 > date2. */
1.239 +IMPORT_C void g_date_order (GDate *date1, GDate *date2);
1.240 +
1.241 +/* Just like strftime() except you can only use date-related formats.
1.242 + * Using a time format is undefined.
1.243 + */
1.244 +IMPORT_C gsize g_date_strftime (gchar *s,
1.245 + gsize slen,
1.246 + const gchar *format,
1.247 + const GDate *date);
1.248 +
1.249 +#ifndef G_DISABLE_DEPRECATED
1.250 +
1.251 +#define g_date_weekday g_date_get_weekday
1.252 +#define g_date_month g_date_get_month
1.253 +#define g_date_year g_date_get_year
1.254 +#define g_date_day g_date_get_day
1.255 +#define g_date_julian g_date_get_julian
1.256 +#define g_date_day_of_year g_date_get_day_of_year
1.257 +#define g_date_monday_week_of_year g_date_get_monday_week_of_year
1.258 +#define g_date_sunday_week_of_year g_date_get_sunday_week_of_year
1.259 +#define g_date_days_in_month g_date_get_days_in_month
1.260 +#define g_date_monday_weeks_in_year g_date_get_monday_weeks_in_year
1.261 +#define g_date_sunday_weeks_in_year g_date_get_sunday_weeks_in_year
1.262 +
1.263 +#endif /* G_DISABLE_DEPRECATED */
1.264 +
1.265 +G_END_DECLS
1.266 +
1.267 +#endif /* __G_DATE_H__ */
1.268 +