3 * Copyright (C) 2009-2010 Christian Hergert <chris@dronelabs.com>
5 * This is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
20 #if defined(G_DISABLE_SINGLE_INCLUDES) && !defined (__GLIB_H_INSIDE__) && !defined (GLIB_COMPILATION)
21 #error "Only <glib.h> can be included directly."
24 #ifndef __G_DATE_TIME_H__
25 #define __G_DATE_TIME_H__
35 * Evaluates to a time span of one day.
39 #define G_TIME_SPAN_DAY (G_GINT64_CONSTANT (86400000000))
44 * Evaluates to a time span of one hour.
48 #define G_TIME_SPAN_HOUR (G_GINT64_CONSTANT (3600000000))
53 * Evaluates to a time span of one minute.
57 #define G_TIME_SPAN_MINUTE (G_GINT64_CONSTANT (60000000))
62 * Evaluates to a time span of one second.
66 #define G_TIME_SPAN_SECOND (G_GINT64_CONSTANT (1000000))
69 * G_TIME_SPAN_MILLISECOND:
71 * Evaluates to a time span of one millisecond.
75 #define G_TIME_SPAN_MILLISECOND (G_GINT64_CONSTANT (1000))
80 * <structname>GDateTime</structname> is an opaque structure whose members
81 * cannot be accessed directly.
85 typedef struct _GDateTime GDateTime
;
90 * A value representing an interval of time, in microseconds.
94 typedef gint64 GTimeSpan
;
96 GDateTime
* g_date_time_new_now (void);
97 GDateTime
* g_date_time_new_today (void);
98 GDateTime
* g_date_time_new_utc_now (void);
99 GDateTime
* g_date_time_new_from_date (gint year
,
102 GDateTime
* g_date_time_new_from_epoch (gint64 secs
);
103 GDateTime
* g_date_time_new_from_timeval (GTimeVal
*tv
);
104 GDateTime
* g_date_time_new_full (gint year
,
110 const gchar
*timezone
);
112 GDateTime
* g_date_time_copy (const GDateTime
*datetime
);
113 GDateTime
* g_date_time_ref (GDateTime
*datetime
);
114 void g_date_time_unref (GDateTime
*datetime
);
116 GDateTime
* g_date_time_add (const GDateTime
*datetime
,
118 GDateTime
* g_date_time_add_days (const GDateTime
*datetime
,
120 GDateTime
* g_date_time_add_hours (const GDateTime
*datetime
,
122 GDateTime
* g_date_time_add_milliseconds (const GDateTime
*datetime
,
124 GDateTime
* g_date_time_add_minutes (const GDateTime
*datetime
,
126 GDateTime
* g_date_time_add_months (const GDateTime
*datetime
,
128 GDateTime
* g_date_time_add_seconds (const GDateTime
*datetime
,
130 GDateTime
* g_date_time_add_weeks (const GDateTime
*datetime
,
132 GDateTime
* g_date_time_add_years (const GDateTime
*datetime
,
134 GDateTime
* g_date_time_add_full (const GDateTime
*datetime
,
142 GDateTime
* g_date_time_day (const GDateTime
*datetime
);
144 gint
g_date_time_compare (gconstpointer dt1
,
146 gboolean
g_date_time_equal (gconstpointer dt1
,
148 guint
g_date_time_hash (gconstpointer datetime
);
150 GTimeSpan
g_date_time_difference (const GDateTime
*begin
,
151 const GDateTime
*end
);
153 void g_date_time_get_julian (const GDateTime
*datetime
,
159 gint
g_date_time_get_hour (const GDateTime
*datetime
);
160 gint
g_date_time_get_minute (const GDateTime
*datetime
);
161 gint
g_date_time_get_second (const GDateTime
*datetime
);
162 gint
g_date_time_get_millisecond (const GDateTime
*datetime
);
163 gint
g_date_time_get_microsecond (const GDateTime
*datetime
);
164 gint
g_date_time_get_day_of_week (const GDateTime
*datetime
);
165 gint
g_date_time_get_day_of_month (const GDateTime
*datetime
);
166 gint
g_date_time_get_day_of_year (const GDateTime
*datetime
);
167 gint
g_date_time_get_month (const GDateTime
*datetime
);
168 gint
g_date_time_get_year (const GDateTime
*datetime
);
169 void g_date_time_get_dmy (const GDateTime
*datetime
,
174 GTimeSpan
g_date_time_get_utc_offset (const GDateTime
*datetime
);
175 G_CONST_RETURN gchar
*g_date_time_get_timezone_name (const GDateTime
*datetime
);
177 gboolean
g_date_time_is_leap_year (const GDateTime
*datetime
);
178 gboolean
g_date_time_is_daylight_savings (const GDateTime
*datetime
);
180 GDateTime
* g_date_time_to_local (const GDateTime
*datetime
);
181 gint64
g_date_time_to_epoch (const GDateTime
*datetime
);
182 void g_date_time_to_timeval (const GDateTime
*datetime
,
184 GDateTime
* g_date_time_to_utc (const GDateTime
*datetime
);
185 gchar
* g_date_time_printf (const GDateTime
*datetime
,
186 const gchar
*format
) G_GNUC_MALLOC
;
190 #endif /* __G_DATE_TIME_H__ */