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 #ifndef __G_DATE_H__
00028 #define __G_DATE_H__
00029
00030 #include <gquark.h>
00031
00032 G_BEGIN_DECLS
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043 typedef gint32 GTime;
00044 typedef guint16 GDateYear;
00045 typedef guint8 GDateDay;
00046 typedef struct _GDate GDate;
00047
00048 struct tm;
00049
00050
00051 typedef enum
00052 {
00053 G_DATE_DAY = 0,
00054 G_DATE_MONTH = 1,
00055 G_DATE_YEAR = 2
00056 } GDateDMY;
00057
00058
00059 typedef enum
00060 {
00061 G_DATE_BAD_WEEKDAY = 0,
00062 G_DATE_MONDAY = 1,
00063 G_DATE_TUESDAY = 2,
00064 G_DATE_WEDNESDAY = 3,
00065 G_DATE_THURSDAY = 4,
00066 G_DATE_FRIDAY = 5,
00067 G_DATE_SATURDAY = 6,
00068 G_DATE_SUNDAY = 7
00069 } GDateWeekday;
00070 typedef enum
00071 {
00072 G_DATE_BAD_MONTH = 0,
00073 G_DATE_JANUARY = 1,
00074 G_DATE_FEBRUARY = 2,
00075 G_DATE_MARCH = 3,
00076 G_DATE_APRIL = 4,
00077 G_DATE_MAY = 5,
00078 G_DATE_JUNE = 6,
00079 G_DATE_JULY = 7,
00080 G_DATE_AUGUST = 8,
00081 G_DATE_SEPTEMBER = 9,
00082 G_DATE_OCTOBER = 10,
00083 G_DATE_NOVEMBER = 11,
00084 G_DATE_DECEMBER = 12
00085 } GDateMonth;
00086
00087 #define G_DATE_BAD_JULIAN 0U
00088 #define G_DATE_BAD_DAY 0U
00089 #define G_DATE_BAD_YEAR 0U
00090
00091
00092
00093
00094
00095
00096 struct _GDate
00097 {
00098 guint julian_days : 32;
00099
00100
00101
00102
00103
00104 guint julian : 1;
00105 guint dmy : 1;
00106
00107
00108 guint day : 6;
00109 guint month : 4;
00110 guint year : 16;
00111 };
00112
00113
00114
00115
00116
00117 GDate* g_date_new (void);
00118 GDate* g_date_new_dmy (GDateDay day,
00119 GDateMonth month,
00120 GDateYear year);
00121 GDate* g_date_new_julian (guint32 julian_day);
00122 void g_date_free (GDate *date);
00123
00124
00125
00126
00127
00128
00129 gboolean g_date_valid (GDate *date);
00130 gboolean g_date_valid_day (GDateDay day) G_GNUC_CONST;
00131 gboolean g_date_valid_month (GDateMonth month) G_GNUC_CONST;
00132 gboolean g_date_valid_year (GDateYear year) G_GNUC_CONST;
00133 gboolean g_date_valid_weekday (GDateWeekday weekday) G_GNUC_CONST;
00134 gboolean g_date_valid_julian (guint32 julian_date) G_GNUC_CONST;
00135 gboolean g_date_valid_dmy (GDateDay day,
00136 GDateMonth month,
00137 GDateYear year) G_GNUC_CONST;
00138
00139 GDateWeekday g_date_get_weekday (GDate *date);
00140 GDateMonth g_date_get_month (GDate *date);
00141 GDateYear g_date_get_year (GDate *date);
00142 GDateDay g_date_get_day (GDate *date);
00143 guint32 g_date_get_julian (GDate *date);
00144 guint g_date_get_day_of_year (GDate *date);
00145
00146
00147
00148
00149
00150
00151 guint g_date_get_monday_week_of_year (GDate *date);
00152 guint g_date_get_sunday_week_of_year (GDate *date);
00153
00154
00155
00156
00157
00158 void g_date_clear (GDate *date,
00159 guint n_dates);
00160
00161
00162
00163
00164
00165 void g_date_set_parse (GDate *date,
00166 const gchar *str);
00167 void g_date_set_time (GDate *date,
00168 GTime time);
00169 void g_date_set_month (GDate *date,
00170 GDateMonth month);
00171 void g_date_set_day (GDate *date,
00172 GDateDay day);
00173 void g_date_set_year (GDate *date,
00174 GDateYear year);
00175 void g_date_set_dmy (GDate *date,
00176 GDateDay day,
00177 GDateMonth month,
00178 GDateYear y);
00179 void g_date_set_julian (GDate *date,
00180 guint32 julian_date);
00181 gboolean g_date_is_first_of_month (GDate *date);
00182 gboolean g_date_is_last_of_month (GDate *date);
00183
00184
00185 void g_date_add_days (GDate *date,
00186 guint n_days);
00187 void g_date_subtract_days (GDate *date,
00188 guint n_days);
00189
00190
00191 void g_date_add_months (GDate *date,
00192 guint n_months);
00193 void g_date_subtract_months (GDate *date,
00194 guint n_months);
00195
00196
00197 void g_date_add_years (GDate *date,
00198 guint n_years);
00199 void g_date_subtract_years (GDate *date,
00200 guint n_years);
00201 gboolean g_date_is_leap_year (GDateYear year) G_GNUC_CONST;
00202 guint8 g_date_get_days_in_month (GDateMonth month,
00203 GDateYear year) G_GNUC_CONST;
00204 guint8 g_date_get_monday_weeks_in_year (GDateYear year) G_GNUC_CONST;
00205 guint8 g_date_get_sunday_weeks_in_year (GDateYear year) G_GNUC_CONST;
00206
00207
00208 gint g_date_compare (GDate *lhs,
00209 GDate *rhs);
00210 void g_date_to_struct_tm (GDate *date,
00211 struct tm *tm);
00212
00213
00214
00215
00216 gsize g_date_strftime (gchar *s,
00217 gsize slen,
00218 const gchar *format,
00219 GDate *date);
00220
00221 G_END_DECLS
00222
00223 #endif
00224