00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028 #ifndef __G_DATE_H__
00029 #define __G_DATE_H__
00030
00031 #include <_ansi.h>
00032 #include <time.h>
00033
00034 #include <glib/gtypes.h>
00035 #include <glib/gquark.h>
00036
00037 G_BEGIN_DECLS
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048 typedef gint32 GTime;
00049 typedef guint16 GDateYear;
00050 typedef guint8 GDateDay;
00051 typedef struct _GDate GDate;
00052
00053 struct tm;
00054
00055
00056 typedef enum
00057 {
00058 G_DATE_DAY = 0,
00059 G_DATE_MONTH = 1,
00060 G_DATE_YEAR = 2
00061 } GDateDMY;
00062
00063
00064 typedef enum
00065 {
00066 G_DATE_BAD_WEEKDAY = 0,
00067 G_DATE_MONDAY = 1,
00068 G_DATE_TUESDAY = 2,
00069 G_DATE_WEDNESDAY = 3,
00070 G_DATE_THURSDAY = 4,
00071 G_DATE_FRIDAY = 5,
00072 G_DATE_SATURDAY = 6,
00073 G_DATE_SUNDAY = 7
00074 } GDateWeekday;
00075 typedef enum
00076 {
00077 G_DATE_BAD_MONTH = 0,
00078 G_DATE_JANUARY = 1,
00079 G_DATE_FEBRUARY = 2,
00080 G_DATE_MARCH = 3,
00081 G_DATE_APRIL = 4,
00082 G_DATE_MAY = 5,
00083 G_DATE_JUNE = 6,
00084 G_DATE_JULY = 7,
00085 G_DATE_AUGUST = 8,
00086 G_DATE_SEPTEMBER = 9,
00087 G_DATE_OCTOBER = 10,
00088 G_DATE_NOVEMBER = 11,
00089 G_DATE_DECEMBER = 12
00090 } GDateMonth;
00091
00092 #define G_DATE_BAD_JULIAN 0U
00093 #define G_DATE_BAD_DAY 0U
00094 #define G_DATE_BAD_YEAR 0U
00095
00096
00097
00098
00099
00100
00101 struct _GDate
00102 {
00103 guint julian_days : 32;
00104
00105
00106
00107
00108
00109 guint julian : 1;
00110 guint dmy : 1;
00111
00112
00113 guint day : 6;
00114 guint month : 4;
00115 guint year : 16;
00116 };
00117
00118
00119
00120
00121
00122 IMPORT_C GDate* g_date_new (void);
00123 IMPORT_C GDate* g_date_new_dmy (GDateDay day,
00124 GDateMonth month,
00125 GDateYear year);
00126 IMPORT_C GDate* g_date_new_julian (guint32 julian_day);
00127 IMPORT_C void g_date_free (GDate *date);
00128
00129
00130
00131
00132
00133
00134 IMPORT_C gboolean g_date_valid (const GDate *date);
00135 IMPORT_C gboolean g_date_valid_day (GDateDay day) G_GNUC_CONST;
00136 IMPORT_C gboolean g_date_valid_month (GDateMonth month) G_GNUC_CONST;
00137 IMPORT_C gboolean g_date_valid_year (GDateYear year) G_GNUC_CONST;
00138 IMPORT_C gboolean g_date_valid_weekday (GDateWeekday weekday) G_GNUC_CONST;
00139 IMPORT_C gboolean g_date_valid_julian (guint32 julian_date) G_GNUC_CONST;
00140 IMPORT_C gboolean g_date_valid_dmy (GDateDay day,
00141 GDateMonth month,
00142 GDateYear year) G_GNUC_CONST;
00143
00144 IMPORT_C GDateWeekday g_date_get_weekday (const GDate *date);
00145 IMPORT_C GDateMonth g_date_get_month (const GDate *date);
00146 IMPORT_C GDateYear g_date_get_year (const GDate *date);
00147 IMPORT_C GDateDay g_date_get_day (const GDate *date);
00148 IMPORT_C guint32 g_date_get_julian (const GDate *date);
00149 IMPORT_C guint g_date_get_day_of_year (const GDate *date);
00150
00151
00152
00153
00154
00155
00156 IMPORT_C guint g_date_get_monday_week_of_year (const GDate *date);
00157 IMPORT_C guint g_date_get_sunday_week_of_year (const GDate *date);
00158 IMPORT_C guint g_date_get_iso8601_week_of_year (const GDate *date);
00159
00160
00161
00162
00163
00164 IMPORT_C void g_date_clear (GDate *date,
00165 guint n_dates);
00166
00167
00168
00169
00170
00171 IMPORT_C void g_date_set_parse (GDate *date,
00172 const gchar *str);
00173 IMPORT_C void g_date_set_time (GDate *date,
00174 time_t timet);
00175 IMPORT_C void g_date_set_time_val (GDate *date,
00176 GTimeVal *timeval);
00177 #ifndef G_DISABLE_DEPRECATED
00178 IMPORT_C void g_date_set_time (GDate *date,
00179 GTime time_);
00180 #endif
00181 IMPORT_C void g_date_set_month (GDate *date,
00182 GDateMonth month);
00183 IMPORT_C void g_date_set_day (GDate *date,
00184 GDateDay day);
00185 IMPORT_C void g_date_set_year (GDate *date,
00186 GDateYear year);
00187 IMPORT_C void g_date_set_dmy (GDate *date,
00188 GDateDay day,
00189 GDateMonth month,
00190 GDateYear y);
00191 IMPORT_C void g_date_set_julian (GDate *date,
00192 guint32 julian_date);
00193 IMPORT_C gboolean g_date_is_first_of_month (const GDate *date);
00194 IMPORT_C gboolean g_date_is_last_of_month (const GDate *date);
00195
00196
00197 IMPORT_C void g_date_add_days (GDate *date,
00198 guint n_days);
00199 IMPORT_C void g_date_subtract_days (GDate *date,
00200 guint n_days);
00201
00202
00203 IMPORT_C void g_date_add_months (GDate *date,
00204 guint n_months);
00205 IMPORT_C void g_date_subtract_months (GDate *date,
00206 guint n_months);
00207
00208
00209 IMPORT_C void g_date_add_years (GDate *date,
00210 guint n_years);
00211 IMPORT_C void g_date_subtract_years (GDate *date,
00212 guint n_years);
00213 IMPORT_C gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST;
00214 IMPORT_C guint8 g_date_get_days_in_month (GDateMonth month,
00215 GDateYear year) G_GNUC_CONST;
00216 IMPORT_C guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST;
00217 IMPORT_C guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST;
00218
00219
00220
00221 IMPORT_C gint g_date_days_between (const GDate *date1,
00222 const GDate *date2);
00223
00224
00225 IMPORT_C gint g_date_compare (const GDate *lhs,
00226 const GDate *rhs);
00227 IMPORT_C void g_date_to_struct_tm (const GDate *date,
00228 struct tm *tm);
00229
00230 IMPORT_C void g_date_clamp (GDate *date,
00231 const GDate *min_date,
00232 const GDate *max_date);
00233
00234
00235 IMPORT_C void g_date_order (GDate *date1, GDate *date2);
00236
00237
00238
00239
00240 IMPORT_C gsize g_date_strftime (gchar *s,
00241 gsize slen,
00242 const gchar *format,
00243 const GDate *date);
00244
00245 #ifndef G_DISABLE_DEPRECATED
00246
00247 #define g_date_weekday g_date_get_weekday
00248 #define g_date_month g_date_get_month
00249 #define g_date_year g_date_get_year
00250 #define g_date_day g_date_get_day
00251 #define g_date_julian g_date_get_julian
00252 #define g_date_day_of_year g_date_get_day_of_year
00253 #define g_date_monday_week_of_year g_date_get_monday_week_of_year
00254 #define g_date_sunday_week_of_year g_date_get_sunday_week_of_year
00255 #define g_date_days_in_month g_date_get_days_in_month
00256 #define g_date_monday_weeks_in_year g_date_get_monday_weeks_in_year
00257 #define g_date_sunday_weeks_in_year g_date_get_sunday_weeks_in_year
00258
00259 #endif
00260
00261 G_END_DECLS
00262
00263 #endif
00264